Answer the question
In order to leave comments, you need to log in
How to convert code from telebot to airogram?
I have a code written on telebot, I need to start in
aiogram
import aiogram
import logging
import faker
from faker import Faker
from aiogram import Bot, Dispatcher, executor, types
from aiogram.dispatcher import Dispatcher, FSMContext
from aiogram.utils import executor
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardRemove
from aiogram.types import ParseMode, Message
from config import *
from keyboard import *
import keyboard as kb
from onesec_api import Mailbox
import json
import asyncio
##discord checker
import requests
logging.basicConfig(level=logging.INFO)
bot = Bot(token=TOKEN)
memory_storage = MemoryStorage()
dp = Dispatcher(bot, storage=memory_storage)
@dp.message_handler(content_types=['document'])
def accept_file(message):
if True:
file_name = message.document.file_name
file_id = message.document.file_name
file_id_info = bot.getFile(message.document.file_id)
downloaded_file = bot.download_file(file_id_info.file_path)
try:
with open(f'{message.chat.id}_tokens.txt', 'wb') as new_file:
new_file.write(downloaded_file)
with open(f'{message.chat.id}_tokens.txt') as txt:
count_valid = 0
count_no_valid = 0
valid = ''
no_valid = ''
bot.send_message(message.chat.id,'Получил токены, начинаю проверку!')
for tokens in txt:
tokens = tokens.replace('\n','')
req = requests.post('https://discord.com/api/v9/invites/cVDH5xRnbh', json={}, headers={'Authorization': tokens}).json()
if req['code'] == 0:
count_no_valid = count_no_valid + 1
no_valid = no_valid+''+tokens+'\n'
print(tokens+' NO VALID!')
else:
count_valid = count_valid + 1
valid = valid+''+tokens+'\n'
print(tokens+' VALID!')
print(valid)
print(no_valid)
with open(str(message.chat.id)+'_no_valid.txt', 'w', encoding='utf-8') as txt_no_valid:
txt_no_valid.write(no_valid)
with open(str(message.chat.id)+'_valid.txt', 'w', encoding='utf-8') as txt_valid:
txt_valid.write(valid)
bot.send_message(message.chat.id,f'Токены проверенны!\nВалид - {count_valid}\nНе валид - {count_no_valid}')
try:
with open(f'{message.chat.id}_no_valid.txt', 'rb') as txt_no_valid:
bot.send_ocument(message.chat.id,txt_no_valid)
except:
bot.send_message(message.chat.id,'Не валида нет!')
try:
with open(f'{message.chat.id}_valid.txt', 'rb') as txt_valid:
bot.send_document(message.chat.id,txt_valid)
except:
bot.send_message(message.chat.id,'Валида нет!')
except:
dp.send_message(message.chat.id,'Что-то не так, файл точно .txt?')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question