diff --git a/ubot.py b/ubot.py index 7228e75..70fcc17 100644 --- a/ubot.py +++ b/ubot.py @@ -9,68 +9,68 @@ client = TelegramClient('ubot', api_id, api_hash) @client.on(events.NewMessage) async def edit(event): - msg = event.raw_text + msg = event.raw_text - if '.alive' in msg: - rpl = "Userbot alive and well!" - msg = event.text.replace(msg, rpl) - await event.edit(msg) + if '.alive' in msg: + rpl = "Userbot alive and well!" + msg = event.text.replace(msg, rpl) + await event.edit(msg) - if '.shg' in msg: - rpl = f"¯\_(ツ)_/¯" - msg = event.text.replace('.shg', rpl) - await event.edit(msg) + if '.shg' in msg: + rpl = f"¯\_(ツ)_/¯" + msg = event.text.replace('.shg', rpl) + await event.edit(msg) - if '.stats' in msg: - pms = bots = 0 - groups = gadmin = gcreator = 0 - chans = cadmin = ccreator = 0 - unread = mentions = 0 - dialog: Dialog + if '.stats' in msg: + pms = bots = 0 + groups = gadmin = gcreator = 0 + chans = cadmin = ccreator = 0 + unread = mentions = 0 + dialog: Dialog - async for dialog in event.client.iter_dialogs(): - entity = dialog.entity + async for dialog in event.client.iter_dialogs(): + entity = dialog.entity - if isinstance(entity, Channel): - if entity.broadcast: - chans += 1 - if entity.creator or entity.admin_rights: - cadmin += 1 - if entity.creator: - ccreator += 1 + if isinstance(entity, Channel): + if entity.broadcast: + chans += 1 + if entity.creator or entity.admin_rights: + cadmin += 1 + if entity.creator: + ccreator += 1 - elif entity.megagroup: - groups += 1 - if entity.creator or entity.admin_rights: - gadmin += 1 - if entity.creator: - gcreator += 1 + elif entity.megagroup: + groups += 1 + if entity.creator or entity.admin_rights: + gadmin += 1 + if entity.creator: + gcreator += 1 - elif isinstance(entity, User): - pms += 1 - if entity.bot: - bots +=1 + elif isinstance(entity, Chat): + groups += 1 + if entity.creator or entity.admin_rights: + gadmin += 1 + if entity.creator: + gcreator += 1 - elif isinstance(entity, Chat): - groups += 1 - if entity.creator or entity.admin_rights: - gadmin += 1 - if entity.creator: - gcreator += 1 + elif isinstance(entity, User): + pms += 1 + if entity.bot: + bots +=1 - mentions += dialog.unread_mentions_count - unread += dialog.unread_count + mentions += dialog.unread_mentions_count + unread += dialog.unread_count - rpl = f'Private chats: {pms} ({pms - bots} users / {bots} bots)\n' - rpl += f'Groups: {groups} ({gadmin} admin / {gcreator} creator)\n' - rpl += f'Channels: {chans} ({cadmin} admin / {ccreator} creator)\n' - rpl += f'Unread: {unread} ({mentions} mentions)\n' - await event.edit(rpl) + rpl = f'Private chats: {pms} ({pms - bots} users / {bots} bots)\n' + rpl += f'Groups: {groups} ({gadmin} admin / {gcreator} creator)\n' + rpl += f'Channels: {chans} ({cadmin} admin / {ccreator} creator)\n' + rpl += f'Unread: {unread} ({mentions} mentions)\n' + await event.edit(rpl) - if '.fire' in msg: - rpl = 'IMA FIRING MAH LAZER' - msg = event.text.replace(msg, rpl) - await event.edit(msg) + if '.fire' in msg: + rpl = 'IMA FIRING MAH LAZER' + msg = event.text.replace(msg, rpl) + await event.edit(msg) client.start() client.run_until_disconnected()