def unblackliststicker(bot: Bot, update: Update): msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] words = msg.text.split(None, 1) conn = connected(bot, update, chat, user.id) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": return else: chat_name = chat.title if len(words) > 1: text = words[1].replace('https://t.me/addstickers/', '') to_unblacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip())) successful = 0 for trigger in to_unblacklist: success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: successful += 1 if len(to_unblacklist) == 1: if successful: send_message(update.effective_message, "Sticker <code>{}</code> içindeki kara listeden silindi <b>{}</b>!".format(html.escape(to_unblacklist[0]), chat_name), parse_mode=ParseMode.HTML) else: send_message(update.effective_message, "Bu çıkartma kara listede değil...!") elif successful == len(to_unblacklist): send_message(update.effective_message, "Sticker <code>{}</code> içindeki kara listeden silindi <b>{}</b>!".format( successful, chat_name), parse_mode=ParseMode.HTML) elif not successful: send_message(update.effective_message, "Bu çıkartmaların hiçbiri mevcut değil, bu yüzden çıkarılamazlar.".format( successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML) else: send_message(update.effective_message, "Sticker <code>{}</code> kara listeden silindi. {} Var olmadı, bu yüzden silinmedi.".format(successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML) elif msg.reply_to_message: trigger = msg.reply_to_message.sticker.set_name if trigger == None: send_message(update.effective_message, "Sticker geçersizdir!") return success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: send_message(update.effective_message, "Sticker <code>{}</code> içindeki kara listeden silindi <b>{}</b>!".format(trigger, chat_name), parse_mode=ParseMode.HTML) else: send_message(update.effective_message, "{} kara listeye alınmış çıkartmalarda bulunamadı...!".format(trigger)) else: send_message(update.effective_message, "Kara listeye hangi çıkartmaları eklemek istediğini söyle.")
def unblackliststicker(update: Update, context: CallbackContext): bot = context.bot msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] words = msg.text.split(None, 1) bot = context.bot conn = connected(bot, update, chat, user.id) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": return chat_name = chat.title if len(words) > 1: text = words[1].replace("https://t.me/addstickers/", "") to_unblacklist = list( { trigger.strip() for trigger in text.split("\n") if trigger.strip() }, ) successful = 0 for trigger in to_unblacklist: success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: successful += 1 if len(to_unblacklist) == 1: if successful: send_message( update.effective_message, "Sticker <code>{}</code> deleted from blacklist in <b>{}</b>!" .format( html.escape(to_unblacklist[0]), html.escape(chat_name), ), parse_mode=ParseMode.HTML, ) else: send_message( update.effective_message, "This sticker is not on the blacklist...!", ) elif successful == len(to_unblacklist): send_message( update.effective_message, "Sticker <code>{}</code> deleted from blacklist in <b>{}</b>!". format( successful, html.escape(chat_name), ), parse_mode=ParseMode.HTML, ) elif not successful: send_message( update.effective_message, "None of these stickers exist, so they cannot be removed.", parse_mode=ParseMode.HTML, ) else: send_message( update.effective_message, "Sticker <code>{}</code> deleted from blacklist. {} did not exist, so it's not deleted." .format( successful, len(to_unblacklist) - successful, ), parse_mode=ParseMode.HTML, ) elif msg.reply_to_message: trigger = msg.reply_to_message.sticker.set_name if trigger is None: send_message(update.effective_message, "Sticker is invalid!") return success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: send_message( update.effective_message, "Sticker <code>{}</code> deleted from blacklist in <b>{}</b>!". format( trigger, chat_name, ), parse_mode=ParseMode.HTML, ) else: send_message( update.effective_message, "{} not found on blacklisted stickers...!".format(trigger), ) else: send_message( update.effective_message, "Tell me what stickers you want to add to the blacklist.", )
def unblackliststicker(update: Update, context: CallbackContext): bot = context.bot msg = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] words = msg.text.split(None, 1) bot = context.bot conn = connected(bot, update, chat, user.id) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": return else: chat_name = chat.title if len(words) > 1: text = words[1].replace('https://t.me/addstickers/', '') to_unblacklist = list( set(trigger.strip() for trigger in text.split("\n") if trigger.strip())) successful = 0 for trigger in to_unblacklist: success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: successful += 1 if len(to_unblacklist) == 1: if successful: send_message( update.effective_message, "<code>{}</code> stikeri <b>{}</b> qrupunda Qara siyahıdan silindi!" .format( html.escape(to_unblacklist[0]), html.escape(chat_name)), parse_mode=ParseMode.HTML) else: send_message(update.effective_message, "Bu stiker Qara siyahıda yoxdur...!") elif successful == len(to_unblacklist): send_message( update.effective_message, "<code>{}</code> stikeri <b>{}</b> qrupunda Qara siyahıdan silindi!" .format(successful, html.escape(chat_name)), parse_mode=ParseMode.HTML) elif not successful: send_message( update.effective_message, "Bu stikerlərdən heç biri mövcud olmadığından silinə bilmədi." .format(successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML) else: send_message( update.effective_message, "<code>{}</code> stikeri Qara siyahıdan silindi. {} mövcud olmadığından silinə bilmədi." .format(successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML) elif msg.reply_to_message: trigger = msg.reply_to_message.sticker.set_name if trigger is None: send_message(update.effective_message, "Stiker xətalıdır!") return success = sql.rm_from_stickers(chat_id, trigger.lower()) if success: send_message( update.effective_message, "<code>{}</code> stikeri <b>{}</b> qrupunda Qara siyahıdan silindi!" .format(trigger, chat_name), parse_mode=ParseMode.HTML) else: send_message( update.effective_message, "{} Qara siyahıda olan stikerlərdən biri deyil...!".format(trigger)) else: send_message(update.effective_message, "Qara siyahıya əlavə etmək istədiyin stikeri verməlisən.")