By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!import asyncio
import logging
from telethon import TelegramClient
from telethon.errors import FloodWaitError
from telethon.tl.functions.account import UpdateStatusRequest
api_id = 1234567
api_hash = "API_HASH"
session_name = "userbot"
logging.basicConfig(level=logging.INFO)
client = TelegramClient(session_name, api_id, api_hash)
async def keep_online():
while True:
try:
await client(UpdateStatusRequest(offline=False))
await client.get_me()
await asyncio.sleep(120)
except FloodWaitError as e:
await asyncio.sleep(e.seconds)
except Exception:
await asyncio.sleep(30)
async def main():
await client.start()
print("Юзербот...
import asyncio
import logging
from telethon import TelegramClient
from telethon.errors import FloodWaitError
from telethon.tl.functions.account import UpdateStatusRequest
api_id = 1234567
api_hash = "API_HASH"
session_name = "userbot"
logging.basicConfig(level=logging.INFO)
client = TelegramClient(session_name, api_id, api_hash)
async def keep_online():
while True:
try:
await client(UpdateStatusRequest(offline=False))
await client.get_me()
await asyncio.sleep(120)
except FloodWaitError as e:
await asyncio.sleep(e.seconds)
except Exception:
await asyncio.sleep(30)
async def main():
await client.start()
print("Юзербот запущен и держит онлайн")
asyncio.create_task(keep_online())
await asyncio.Event().wait()
asyncio.run(main())