''' Basic functions mod ''' import asyncio from telethon import events from telethon.tl.types import PeerUser, PeerChat, PeerChannel import utils _config = None async def mod_init(config: dict) -> bool: ''' Initialize the mod ''' global _config _config = config print('[I] mod_basic is initialized') async def mod_deinit() -> None: ''' Deinitialize the mod ''' print('[I] mod_basic is deinitialized') def mod_get_mighty() -> bool: ''' Mod is called 'mighty' if it receives all messages ''' return False def mod_get_tags() -> None: ''' Get tags used by the mod ''' return ['base', 'base_peerid'] async def mod_new_message(session, event) -> None: ''' Handle new message ''' try: # get the message msg = event.message # not outgoing - do not process if not msg.out: return # get the text text = None try: text = msg.message if not text: return except: return # get args args = [i for i in text.split(' ') if i] # cmd and args cmd = args[0].lower() args = args[1:] # no args if cmd == 'base': if args: return response_text = 'tg-utility available mods:' mods = utils.get_all_mods() for mod in mods: response_text += '\n - %s' % mod response_text += '\n\nmod_basic commands:' response_text += '\n - base_peerid - get peer ID of current chat' await event.reply(message=response_text) elif cmd == 'base_peerid': if args: return peer = msg.peer_id await event.reply(message=utils.peer_to_id(msg.peer_id)) except: utils.pex()