Compare commits

..

2 Commits

Author SHA1 Message Date
blank X 33c0440f13
Hide bot when using the userbot for lolis 2021-05-07 20:22:27 +07:00
blank X bee3e4fc43
Handle ChatSendInlineForbidden 2021-05-07 20:11:56 +07:00
4 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,7 @@ import html
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.types.messages_and_media import Photo from pyrogram.types.messages_and_media import Photo
from pyrogram.errors.exceptions.forbidden_403 import Forbidden from pyrogram.errors.exceptions.forbidden_403 import Forbidden
from pyrogram.errors.exceptions.bad_request_400 import ChatSendInlineForbidden
from .. import slave, config, help_dict, log_errors, public_log_errors from .. import slave, config, help_dict, log_errors, public_log_errors
@Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['anilist', 'al', 'alc', 'alchar', 'alcharacter', 'anilistc', 'anilistchar', 'anilistcharacter'], prefixes=config['config']['prefixes'])) @Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['anilist', 'al', 'alc', 'alchar', 'alcharacter', 'anilistc', 'anilistchar', 'anilistcharacter'], prefixes=config['config']['prefixes']))
@ -30,7 +31,7 @@ async def anilist(client, message):
await message.reply_inline_bot_result(results.query_id, results.results[page].id) await message.reply_inline_bot_result(results.query_id, results.results[page].id)
except IndexError: except IndexError:
await message.reply_text(f'There are only {len(results.results)} results') await message.reply_text(f'There are only {len(results.results)} results')
except Forbidden: except (Forbidden, ChatInlineSendForbidden):
text = {'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities} text = {'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities}
try: try:
photo = Photo._parse(client, results.results[page].photo) photo = Photo._parse(client, results.results[page].photo)

View File

@ -1,4 +1,5 @@
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.types.messages_and_media import Photo
from pyrogram.errors.exceptions.forbidden_403 import Forbidden from pyrogram.errors.exceptions.forbidden_403 import Forbidden
from .. import slave, config, help_dict, log_errors, public_log_errors from .. import slave, config, help_dict, log_errors, public_log_errors
@ -9,10 +10,12 @@ async def loli(client, message):
bot = await slave.get_me() bot = await slave.get_me()
query = ' '.join(message.command) query = ' '.join(message.command)
results = await client.get_inline_bot_results(bot.username or bot.id, query) results = await client.get_inline_bot_results(bot.username or bot.id, query)
result = results.results[0]
photo = Photo._parse(client, result.photo)
try: try:
await message.reply_inline_bot_result(results.query_id, results.results[0].id) await message.reply_cached_media(photo.file_id, caption={'message': result.send_message.message, 'entities': result.send_message.entities}, parse_mode='through')
except Forbidden: except Forbidden:
await message.reply_text({'message': results.results[0].send_message.message, 'entities': results.results[0].send_message.entities}, disable_web_page_preview=True, parse_mode='through') await message.reply_text({'message': result.send_message.message, 'entities': result.send_message.entities}, parse_mode='through')
help_dict['loli'] = ('Loli', help_dict['loli'] = ('Loli',
'''{prefix}loli <i>[keywords]</i> - Gets a possibly nsfw image of a loli, thanks to lolicon.app '''{prefix}loli <i>[keywords]</i> - Gets a possibly nsfw image of a loli, thanks to lolicon.app

View File

@ -1,5 +1,6 @@
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.errors.exceptions.forbidden_403 import Forbidden from pyrogram.errors.exceptions.forbidden_403 import Forbidden
from pyrogram.errors.exceptions.bad_request_400 import ChatSendInlineForbidden
from .. import slave, config, help_dict, log_errors, public_log_errors from .. import slave, config, help_dict, log_errors, public_log_errors
@Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['ud', 'urbandictionary'], prefixes=config['config']['prefixes'])) @Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['ud', 'urbandictionary'], prefixes=config['config']['prefixes']))
@ -28,7 +29,7 @@ async def ud(client, message):
await message.reply_inline_bot_result(results.query_id, results.results[page].id) await message.reply_inline_bot_result(results.query_id, results.results[page].id)
except IndexError: except IndexError:
await message.reply_text(f'There are only {len(results.results)} definitions') await message.reply_text(f'There are only {len(results.results)} definitions')
except Forbidden: except (Forbidden, ChatInlineSendForbidden):
await message.reply_text({'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities}, disable_web_page_preview=True, parse_mode='through') await message.reply_text({'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities}, disable_web_page_preview=True, parse_mode='through')
help_dict['ud'] = ('Urban Dictionary', help_dict['ud'] = ('Urban Dictionary',

View File

@ -1,5 +1,6 @@
from pyrogram import Client, filters from pyrogram import Client, filters
from pyrogram.errors.exceptions.forbidden_403 import Forbidden from pyrogram.errors.exceptions.forbidden_403 import Forbidden
from pyrogram.errors.exceptions.bad_request_400 import ChatSendInlineForbidden
from .. import slave, config, help_dict, log_errors, public_log_errors from .. import slave, config, help_dict, log_errors, public_log_errors
@Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['w', 'wiki', 'wikipedia'], prefixes=config['config']['prefixes'])) @Client.on_message(~filters.forwarded & ~filters.sticker & ~filters.via_bot & ~filters.edited & filters.me & filters.command(['w', 'wiki', 'wikipedia'], prefixes=config['config']['prefixes']))
@ -28,7 +29,7 @@ async def wikipedia(client, message):
await message.reply_inline_bot_result(results.query_id, results.results[page].id) await message.reply_inline_bot_result(results.query_id, results.results[page].id)
except IndexError: except IndexError:
await message.reply_text(f'There are only {len(results.results)} results') await message.reply_text(f'There are only {len(results.results)} results')
except Forbidden: except (Forbidden, ChatInlineSendForbidden):
await message.reply_text({'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities}, disable_web_page_preview=True, parse_mode='through') await message.reply_text({'message': results.results[page].send_message.message, 'entities': results.results[page].send_message.entities}, disable_web_page_preview=True, parse_mode='through')
help_dict['wikipedia'] = ('Wikipedia', help_dict['wikipedia'] = ('Wikipedia',