def Search_Command(bot, message): if (Search_Allowed or Message_From_Admin( bot, message)) and message.chat.type in Constant_Block.Search: pattern = re.compile(r'[\w\s+-=?!]+', re.UNICODE) result = pattern.findall(message.text, pos=8) string = '' for i in result: string += i string = re.sub(r'\s+', r' ', string) string = re.sub(r'\++', r'+', string) string = re.sub(r'\-+', r'-', string) string = re.sub(r'\?+', r'?', string) string = re.sub(r'\!+', r'!', string) query = urllib.parse.urlencode({'q': string}, encoding='cp1251') url = f'https://www.google.ru/search?{query}' bot.send_message(message.chat.id, url) elif message.chat.type not in Constant_Block.Search: Response_Block.Deleter(bot, message.chat.id, message.message_id) Response_Block.Error_NoAllowed(bot, message.from_user.id, message.from_user.language_code) else: Response_Block.Deleter(bot, message.chat.id, message.message_id) del message
def Text(bot, message): if (message.chat.type in Constant_Block.Type_Groups and Constant_Block.Text) or Message_From_Admin(bot, message): pass else: Response_Block.Deleter(bot, message.chat.id, message.message_id) del message
def Menu_Command(bot, message): if (Menu_Allowed and Message_From_Admin( bot, message)) and message.chat.type in Constant_Block.Menu: try: bot.send_message(message.chat.id, 'Извените, находится в разработке') except apihelper.ApiException: pass elif message.chat.type not in Constant_Block.Menu: Response_Block.Deleter(bot, message.chat.id, message.message_id) Response_Block.Error_NoAllowed(bot, message.from_user.id, message.from_user.language_code) else: Response_Block.Deleter(bot, message.chat.id, message.message_id) del message