from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.account.UpdateStatusRequest(
offline=False
))
print(result)
def users_in_db(message):
with sqlite3.connect(db) as conn:
with conn.cursor() as cursor:
sql_users_in_db = """SELECT chat_id FROM users WHERE chat_id = ?;"""
cursor.execute(sql_users_in_db, message.chat.id)
users = cursor.fetchall()
print(users)
if users:
return True
return False
@dp.message_handler(commands=["users"])
async def process_start_command(message: Message):
if users_in_db(message):
print("зареган")
else:
print("не зареган")
To fix this error install pymongo with the srv extra...
python -m pip install "pymongo[srv]"
A limited account with one web app at your-username.pythonanywhere.com, restricted outbound Internet access from your apps, low CPU/bandwidth, no IPython/Jupyter notebook support.
It works and it's a great way to get started!
bot.clear_step_handler_by_chat_id(chat_id=call.message.chat.id)
@bot.message_handler(commands=['start'])
def process_start(message):
board = types.InlineKeyboardMarkup()
cancel = types.InlineKeyboardButton(text="Отмена", callback_data="Отмена")
board.add(cancel)
text = 'start'
msg = bot.send_message(message.chat.id, text, reply_markup=board)
bot.register_next_step_handler(msg, process_mid)
def process_mid(message):
board = types.InlineKeyboardMarkup()
cancel = types.InlineKeyboardButton(text="Отмена", callback_data="Отмена")
board.add(cancel)
text = 'mid'
msg = bot.send_message(message.chat.id, text, reply_markup=board)
bot.register_next_step_handler(msg, process_end)
def process_end(message):
text = 'end'
bot.send_message(message.chat.id, text)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
if call.message:
if call.data == "Отмена":
bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text='Отменено.')
bot.clear_step_handler_by_chat_id(chat_id=call.message.chat.id)
bot.polling(none_stop=True)