async def _(event): name = event.pattern_match.group(1) msg = await event.get_reply_message() if msg: snip = {"type": TYPE_TEXT, "text": msg.message or ""} if msg.media: media = None if isinstance(msg.media, types.MessageMediaPhoto): media = utils.get_input_photo(msg.media.photo) snip["type"] = TYPE_PHOTO elif isinstance(msg.media, types.MessageMediaDocument): media = utils.get_input_document(msg.media.document) snip["type"] = TYPE_DOCUMENT if media: snip["id"] = media.id snip["hash"] = media.access_hash snip["fr"] = media.file_reference add_snip( name, snip["text"], snip["type"], snip.get("id"), snip.get("hash"), snip.get("fr"), ) await event.reply( "Note {name} saved successfully. Get it with ?{name}".format( name=name)) else: await event.reply( "Reply to a message with `snips keyword` to save the snip")
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AttributeError: return await event.edit("`Running on Non-SQL mode!`") keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\nKEYWORD: {keyword}" "\n\nThe following message is saved as the data for the snip, " "please do NOT delete it !!" ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: return await event.edit( "`Saving snips with media requires the BOTLOG_CHATID to be set.`" ) elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {} successfully. Use` **${}** `anywhere to get it`" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format('updated', keyword)) else: await event.edit(success.format('saved', keyword))
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Running on Non-SQL mode!`") return name = event.pattern_match.group(1) msg = await event.get_reply_message() if not msg: await event.edit("`I need something to save as a snip.`") return elif BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKEYWORD: {name}\ \nThe following message is saved as the data for the snip, please do NOT delete it !!" ) msg_o = await event.client.forward_messages(entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) success = "`Snip {} successfully. Use` **${}** `anywhere to get it`" if add_snip(name, msg_o.id) is False: await event.edit(success.format('updated', name)) else: await event.edit(success.format('saved', name)) else: await event.edit( "`This feature requires the BOTLOG_CHATID to be set up.`") return
async def on_snip_save(event): """ .snip əmri daha sonra istifadə edə biləcəyiniz snipi yadda saxlayar. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit(LANG['NO_SQL']) return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKELIME: {keyword}\ \n\nAşağıdaki mesaj snip üçün məlumat olaraq yaddaşda saxlanar!!") msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: await event.edit(LANG['NEED_BOTLOG']) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {}. {}:` **${}** `" if add_snip(keyword, string, msg_id) is False: await event.edit( success.format(LANG['UPDATED'], LANG['USAGE'], keyword)) else: await event.edit(success.format(LANG['SAVED'], LANG['USAGE'], keyword))
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Running on Non-SQL mode!`") return name = event.pattern_match.group(1) msg = await event.get_reply_message() if not msg: await event.edit("`I need something to save as a snip.`") return else: snip = {'type': TYPE_TEXT, 'text': msg.message or ''} if msg.media: media = None if isinstance(msg.media, types.MessageMediaPhoto): media = utils.get_input_photo(msg.media.photo) snip['type'] = TYPE_PHOTO elif isinstance(msg.media, types.MessageMediaDocument): media = utils.get_input_document(msg.media.document) snip['type'] = TYPE_DOCUMENT if media: snip['id'] = media.id snip['hash'] = media.access_hash snip['fr'] = media.file_reference success = "**Snip {} successfully. Use** `₹{}` **anywhere to get it**" if add_snip(name, snip['text'], snip['type'], snip.get('id'), snip.get('hash'), snip.get('fr')) is False: await event.edit(success.format('updated', name)) else: await event.edit(success.format('saved', name))
async def on_snip_save(event): """For .costum command, saves costums for future use.""" try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Berjalan pada mode Non-SQL!`") return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#COSTUM\ \nKEYWORD: {keyword}\ \n\nPesan berikut disimpan sebagai data untuk costum, tolong JANGAN dihapus untuk catatan!!", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: await event.edit( "`Menyimpan kostum dengan media membutuhkan BOTLOG_CHATID untuk disetel.`" ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = ( "**Costum {} disimpan. Gunakan** `.{}` **di mana saja untuk menggunakannya**" ) if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("Sukses", keyword)) else: await event.edit(success.format("Sukses", keyword))
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AttributeError: return await event.edit("`Running on Non-SQL mode!`") keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\nKEYWORD: {keyword}" "\n\nPesan berikut disimpan sebagai data untuk snip, " "tolong JANGAN menghapusnya !!", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: return await event.edit( "`Saving snips with media requires the BOTLOG_CHATID to be set.`" ) elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {} berhasil. Gunakan` `${}` `di mana saja untuk mendapatkannya`" try: if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("perbarui", keyword)) else: await event.edit(success.format("tersimpan", keyword)) except UnmappedInstanceError: return await event.edit(f"`Snip` `{keyword}` `sudah ada.`")
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AttributeError: return await event.edit("**Executando em modo não SQL!**") keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\nPALAVRA-CHAVE: {keyword}" "\n\nA seguinte mensagem é salva como os dados para o snip, " "por favor, NÃO o exclua!", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: return await event.edit( "**Salvar snips com mídia requer que BOTLOG_CHATID seja definido.**" ) elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "**Snip {} com sucesso. Use** `${}` **em qualquer lugar para usá-lo**" try: if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("atualizado", keyword)) else: await event.edit(success.format("salvo", keyword)) except UnmappedInstanceError: return await event.edit(f"**Erro: Snip** `{keyword}` **já existe.**")
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AttributeError: return await event.edit("`Berjalan di mode Non-SQL!`") keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\n**Kata Kunci** : {keyword}" "\n\nPesan berikut disimpan sebagai data potongan media." "\n**Tolong jangan dihapus!**", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: return await event.edit( "`Untuk menyimpan potongan media, BOTLOG_CHATID harus disetel.`" ) elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Berhasil memotong` **{}**.\n`Gunakan` **${}** `di mana saja untuk mendapatkannya.`" try: if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("diperbarui", keyword)) else: await event.edit(success.format("disimpan", keyword)) except UnmappedInstanceError: return await event.edit(f"`.snip` **{keyword}** `sudah ada.`")
async def on_snip_save(event): """ .snip komutu gelecekte kullanılmak üzere snips kaydeder. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit(LANG['NO_SQL']) return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKELIME: {keyword}\ \n\nAşağıdaki mesaj snip için veri olarak kaydedilir, lütfen silmeyin !!" ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: await event.edit( LANG['NEED_BOTLOG'] ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {}. {}:` **${}** `" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format(LANG['UPDATED'], LANG['USAGE'], keyword)) else: await event.edit(success.format(LANG['SAVED'], LANG['USAGE'], keyword))
async def on_snip_save(event): """ .snip komutu gelecekte kullanılmak üzere snips kaydeder. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`SQL dışı modda çalışıyor!`") return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKELIME: {keyword}\ \n\nAşağıdaki mesaj snip için veri olarak kaydedilir, lütfen silmeyin !!" ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: await event.edit( "`Snip'leri medya ile kaydetmek için BOTLOG_CHATID ayarlanması gerekir.`" ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {}. Kullanım:` **${}** `" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format('güncellendi', keyword)) else: await event.edit(success.format('kaydedildi', keyword))
async def on_snip_save(event): """ Untuk perintah .snip, simpan snips untuk digunakan di masa mendatang. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Berjalan pada mode Non-SQL!`") return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKEYWORD: {keyword}\ \n\nPesan berikut disimpan sebagai data untuk snip, tolong JANGAN menghapusnya !!" ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True) msg_id = msg_o.id else: await event.edit( "`Untuk menyimpan potongan dengan media, BOTLOG_CHATID harus disetel.`" ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Berhasil memotong {}. Gunakan` **${}** `di mana saja untuk mendapatkannya`" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format('updated', keyword)) else: await event.edit(success.format('saved', keyword))
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Executando em modo não-SQL!`") return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nPALAVRA CHAVE: {keyword}\ \n\nA mensagem a seguir é salva como os dados do recorte, NÃO a exclua !!", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True ) msg_id = msg_o.id else: await event.edit( "`Salvar recortes com mídia requer que BOTLOG_CHATID seja definido.`" ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Recorte {} com sucesso. Use` **${}** `em qualquer lugar para obtê-lo`" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("atualizado", keyword)) else: await event.edit(success.format("salvo", keyword))
async def on_snip_save(event): """ For .snip command, saves snips for future use. """ try: from userbot.modules.sql_helper.snips_sql import add_snip except AtrributeError: await event.edit("`Berjalan pada mode Non-SQL!`") return keyword = event.pattern_match.group(1) string = event.text.partition(keyword)[2] msg = await event.get_reply_message() msg_id = None if msg and msg.media and not string: if BOTLOG_CHATID: await event.client.send_message( BOTLOG_CHATID, f"#SNIP\ \nKEYWORD: {keyword}\ \n\nPesan berikut disimpan sebagai data untuk snip, tolong JANGAN di hapus!!", ) msg_o = await event.client.forward_messages( entity=BOTLOG_CHATID, messages=msg, from_peer=event.chat_id, silent=True ) msg_id = msg_o.id else: await event.edit( "`Saving snips with media requires the BOTLOG_CHATID to be set.`" ) return elif event.reply_to_msg_id and not string: rep_msg = await event.get_reply_message() string = rep_msg.text success = "`Snip {} berhasil. Gunakan` **${}** `di mana saja untuk mendapatkannya`" if add_snip(keyword, string, msg_id) is False: await event.edit(success.format("updated", keyword)) else: await event.edit(success.format("saved", keyword))