client.send_message('me', '<a href="tg://user?id=me">Mentions</a>', parse_mode="html")
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.types import BotCommand
from aiogram.contrib.fsm_storage.memory import MemoryStorage
async def set_commands(bot: Bot):
commands = [
BotCommand(command="/drinks", description="Заказать напитки"),
BotCommand(command="/food", description="Заказать блюда"),
BotCommand(command="/cancel", description="Отменить текущее действие")
]
await bot.set_my_commands(commands)
from telethon import TelegramClient, events, utils
import os
session = os.environ.get('TG_SESSION', 'printer')
api_id = '888888888'
api_hash = '8888888888888888888888'
client = TelegramClient(session, api_id, api_hash, retry_delay=30, auto_reconnect=True).start()
@client.on(events.NewMessage())
async def handler_all(event):
chat_id = event.chat_id #ID чата
sender_id = event.sender_id # Получаем ID Юзера
msg_id = event.id # Получаем ID сообщения
sender = await event.get_sender() # получаем имя юзера
name = utils.get_display_name(sender) # Имя Юзера
chat_from = event.chat if event.chat else (await event.get_chat()) # получаем имя группы
chat_title = utils.get_display_name(chat_from) # получаем имя группы
print(f"ID: {chat_id} {chat_title} >> (ID: {sender_id}) {name} - (ID: {msg_id}) {event.text}")
with client:
client.run_until_disconnected()
>>> numpy.format_float_positional(0.000000054321654321)
'0.000000054321654321'
>>> numpy.format_float_positional(0.00000005)
'0.00000005'
>>> numpy.format_float_positional(0.1)
'0.1'
>>> numpy.format_float_positional(4.5678e-20)
'0.000000000000000000045678'
with open('test.txt', 'r') as file:
v1, v2 = file.readline().split(';')
print(v1, v2)
with open('test.txt', 'r') as file:
lineindex = 0
for line in file:
values = line.split(';')
for colindex in range(len(values)):
globals()[f'v_{lineindex}_{colindex}'] = values[colindex]
lineindex += 1
print(v_0_0, v_0_1)
with open('test.txt', 'r') as file:
acc = []
for line in file:
acc.append(line.split(';'))
print(acc)
with open('file.txt', 'r') as file:
content = str(file.readlines()).split(';')