@bot.message_handler(content_types=['text'])
def hello(message):
if message.text == '/start':
sent = bot.send_message(message.from_user.id, "Введите имя");
bot.register_next_step_handler(sent, get_name);
else:
bot.send_message(message.from_user.id, '/start');
def get_name(message):
name = message.text
print(name)
async def remove_messages(ctx, author, count):
total_messages = 0
author_messages = 0
async for message in channel.history(limit=None):
total_messages += 1
if message.author == author:
author_messages += 1
if author_messages == count:
break
await ctx.channel.purge(limit = total_messages, check = lambda message: message.author == member)
import requests
data = [{"operationName":"EventExhibitorList","variables":{"viewId":"RXZlbnRWaWV3XzE1MjUyMA==","search":"","selectedFilters":[{"mustEventFiltersIn":[]}]},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"ee232939a5b943c0d87a4877655179bc2e5c73472ff99814119deddb34e0a3b6"}}}]
response = requests.post('https://api.swapcard.com/graphql', json=data).json()
# парсим нужные данные тут
end_cursor = response[0]['data']['view']['exhibitors']['pageInfo'].get('endCursor')
while end_cursor:
data = [{"operationName":"EventExhibitorList","variables":{"viewId":"RXZlbnRWaWV3XzE1MjUyMA==","search":"","selectedFilters":[{"mustEventFiltersIn":[]}],"endCursor":end_cursor},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"ee232939a5b943c0d87a4877655179bc2e5c73472ff99814119deddb34e0a3b6"}}}]
response = requests.post('https://api.swapcard.com/graphql', json=data).json()
# тут парсим нужные данные
end_cursor = response[0]['data']['view']['exhibitors']['pageInfo'].get('endCursor')
@bot.callback_query_handler(func = lambda call: True)
def callback_inline(call):
global first
first = ["Well done! Now I have to define your name.", "ikki"]
if call.data == 'eng':
first = str(first[0])
main(call)
elif call.data == 'ru':
first = str(first[1])
main(call)
elif call.data == 'yes':
bot.edit_message_text('Отлично', call.message.chat.id, call.message.message_id)
body()
else:
bot.edit_message_text('Плохо', call.message.chat.id, call.message.message_id)
body()
try:
chat = await client(ResolveUsernameRequest(username))
result = {
'chat_id': chat.peer.channel_id,
'access_hash': chat.chats[0].access_hash,
'title': chat.chats[0].title,
'username': username
}
except Exception as e:
result = None
ResolveUsernameRequest
не резолвит id из joinchat ссылки.from telethon.tl.functions.messages import CheckChatInviteRequest
chat = client(CheckChatInviteRequest('XXXXXXXXXXXX'))
headers = ['Название продукции', 'Количество продукции']
n = int(input('Введите кол-во наименований: '))
with open('file.csv', 'w', newline = '') as csvfile:
writer = csv.writer(csvfile, delimiter = ';')
writer.writerow(headers)
for _ in range(n):
name = input('Введите название: ')
count = input('Кол-во: ')
writer.writerow([name, count])