本文整理汇总了Python中telegram.ext.Filters.sticker方法的典型用法代码示例。如果您正苦于以下问题:Python Filters.sticker方法的具体用法?Python Filters.sticker怎么用?Python Filters.sticker使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类telegram.ext.Filters
的用法示例。
在下文中一共展示了Filters.sticker方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_lock_message
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def build_lock_message(chat_id):
locks = sql.get_locks(chat_id)
restr = sql.get_restr(chat_id)
if not (locks or restr):
res = "There are no current locks in this chat."
else:
res = "These are the locks in this chat:"
if locks:
res += "\n - sticker = `{}`" \
"\n - audio = `{}`" \
"\n - voice = `{}`" \
"\n - document = `{}`" \
"\n - video = `{}`" \
"\n - videonote = `{}`" \
"\n - contact = `{}`" \
"\n - photo = `{}`" \
"\n - gif = `{}`" \
"\n - url = `{}`" \
"\n - bots = `{}`" \
"\n - forward = `{}`" \
"\n - game = `{}`" \
"\n - location = `{}`".format(locks.sticker, locks.audio, locks.voice, locks.document,
locks.video, locks.videonote, locks.contact, locks.photo, locks.gif, locks.url,
locks.bots, locks.forward, locks.game, locks.location)
if restr:
res += "\n - messages = `{}`" \
"\n - media = `{}`" \
"\n - other = `{}`" \
"\n - previews = `{}`" \
"\n - all = `{}`".format(restr.messages, restr.media, restr.other, restr.preview,
all([restr.messages, restr.media, restr.other, restr.preview]))
return res
示例2: add_smile_mode
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def add_smile_mode(upd: Updater, handlers_group: int):
""" Set up all handler for SmileMode """
logger.info("registering smile-mode handlers")
dp = upd.dispatcher
dp.add_handler(MessageHandler(~Filters.sticker & ~Filters.animation, smile), handlers_group)
示例3: build_lock_message
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def build_lock_message(chat_id):
locks = sql.get_locks(chat_id)
restr = sql.get_restr(chat_id)
if not (locks or restr):
res = "There are no current locks in this chat."
else:
res = "These are the locks in this chat:"
if locks:
res += "\n - sticker = `{}`" \
"\n - audio = `{}`" \
"\n - voice = `{}`" \
"\n - document = `{}`" \
"\n - video = `{}`" \
"\n - contact = `{}`" \
"\n - photo = `{}`" \
"\n - gif = `{}`" \
"\n - url = `{}`" \
"\n - bots = `{}`" \
"\n - forward = `{}`" \
"\n - game = `{}`" \
"\n - location = `{}`".format(locks.sticker, locks.audio, locks.voice, locks.document,
locks.video, locks.contact, locks.photo, locks.gif, locks.url,
locks.bots, locks.forward, locks.game, locks.location)
if restr:
res += "\n - messages = `{}`" \
"\n - media = `{}`" \
"\n - other = `{}`" \
"\n - previews = `{}`" \
"\n - all = `{}`".format(restr.messages, restr.media, restr.other, restr.preview,
all([restr.messages, restr.media, restr.other, restr.preview]))
return res
示例4: add_blackliststicker
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def add_blackliststicker(update, context):
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(context.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_blacklist = list(set(trigger.strip() for trigger in text.split("\n") if trigger.strip()))
added = 0
for trigger in to_blacklist:
try:
get = context.bot.getStickerSet(trigger)
sql.add_to_stickers(chat_id, trigger.lower())
added += 1
except BadRequest:
send_message(update.effective_message, tl(update.effective_message, "Stiker `{}` tidak dapat di temukan!").format(trigger), parse_mode="markdown")
if added == 0:
return
if len(to_blacklist) == 1:
send_message(update.effective_message, tl(update.effective_message, "Stiker <code>{}</code> ditambahkan ke daftar hitam stiker di <b>{}</b>!").format(html.escape(to_blacklist[0]), chat_name),
parse_mode=ParseMode.HTML)
else:
send_message(update.effective_message, tl(update.effective_message, "<code>{}</code> stiker ditambahkan ke daftar hitam stiker di <b>{}</b>!").format(added, chat_name), parse_mode=ParseMode.HTML)
elif msg.reply_to_message:
added = 0
trigger = msg.reply_to_message.sticker.set_name
if trigger == None:
send_message(update.effective_message, tl(update.effective_message, "Stiker tidak valid!"))
return
try:
get = context.bot.getStickerSet(trigger)
sql.add_to_stickers(chat_id, trigger.lower())
added += 1
except BadRequest:
send_message(update.effective_message, tl(update.effective_message, "Stiker `{}` tidak dapat di temukan!").format(trigger), parse_mode="markdown")
if added == 0:
return
send_message(update.effective_message, tl(update.effective_message, "Stiker <code>{}</code> ditambahkan ke daftar hitam stiker di <b>{}</b>!").format(trigger, chat_name), parse_mode=ParseMode.HTML)
else:
send_message(update.effective_message, tl(update.effective_message, "Beri tahu saya stiker apa yang ingin Anda tambahkan ke daftar hitam stiker."))
示例5: unblackliststicker
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def unblackliststicker(update, context):
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(context.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, tl(update.effective_message, "Stiker <code>{}</code> dihapus dari daftar hitam di <b>{}</b>!").format(html.escape(to_unblacklist[0]), chat_name),
parse_mode=ParseMode.HTML)
else:
send_message(update.effective_message, tl(update.effective_message, "Ini tidak ada di daftar hitam stiker...!"))
elif successful == len(to_unblacklist):
send_message(update.effective_message, tl(update.effective_message, "Stiker <code>{}</code> dihapus dari daftar hitam di <b>{}</b>!").format(
successful, chat_name), parse_mode=ParseMode.HTML)
elif not successful:
send_message(update.effective_message, tl(update.effective_message, "Tidak satu pun stiker ini ada, sehingga tidak dapat dihapus.").format(
successful, len(to_unblacklist) - successful), parse_mode=ParseMode.HTML)
else:
send_message(update.effective_message, tl(update.effective_message,
"Stiker <code>{}</code> dihapus dari daftar hitam. {} Tidak ada, "
"jadi tidak dihapus.").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, tl(update.effective_message, "Stiker tidak valid!"))
return
success = sql.rm_from_stickers(chat_id, trigger.lower())
if success:
send_message(update.effective_message, tl(update.effective_message, "Stiker <code>{}</code> dihapus dari daftar hitam di <b>{}</b>!").format(trigger, chat_name),
parse_mode=ParseMode.HTML)
else:
send_message(update.effective_message, tl(update.effective_message, "{} tidak ada di daftar hitam stiker...!").format(trigger))
else:
send_message(update.effective_message, tl(update.effective_message, "Beri tahu saya stiker apa yang ingin Anda tambahkan ke daftar hitam stiker."))
示例6: del_blackliststicker
# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import sticker [as 别名]
def del_blackliststicker(update, context):
chat = update.effective_chat # type: Optional[Chat]
message = update.effective_message # type: Optional[Message]
user = update.effective_user
to_match = message.sticker
if not to_match:
return
getmode, value = sql.get_blacklist_setting(chat.id)
chat_filters = sql.get_chat_stickers(chat.id)
for trigger in chat_filters:
if to_match.set_name.lower() == trigger.lower():
try:
if getmode == 0:
return
elif getmode == 1:
message.delete()
elif getmode == 2:
message.delete()
warn(update.effective_user, chat, tl(update.effective_message, "Menggunakan stiker '{}' yang ada di daftar hitam stiker").format(trigger), message, update.effective_user, conn=False)
return
elif getmode == 3:
message.delete()
bot.restrict_chat_member(chat.id, update.effective_user.id, can_send_messages=False)
bot.sendMessage(chat.id, tl(update.effective_message, "{} di bisukan karena menggunakan stiker '{}' yang ada di daftar hitam stiker").format(mention_markdown(user.id, user.first_name), trigger), parse_mode="markdown")
return
elif getmode == 4:
message.delete()
res = chat.unban_member(update.effective_user.id)
if res:
bot.sendMessage(chat.id, tl(update.effective_message, "{} di tendang karena menggunakan stiker '{}' yang ada di daftar hitam stiker").format(mention_markdown(user.id, user.first_name), trigger), parse_mode="markdown")
return
elif getmode == 5:
message.delete()
chat.kick_member(user.id)
bot.sendMessage(chat.id, tl(update.effective_message, "{} di blokir karena menggunakan stiker '{}' yang ada di daftar hitam stiker").format(mention_markdown(user.id, user.first_name), trigger), parse_mode="markdown")
return
elif getmode == 6:
message.delete()
bantime = extract_time(message, value)
chat.kick_member(user.id, until_date=bantime)
bot.sendMessage(chat.id, tl(update.effective_message, "{} di blokir selama {} karena menggunakan stiker '{}' yang ada di daftar hitam stiker").format(mention_markdown(user.id, user.first_name), value, trigger), parse_mode="markdown")
return
elif getmode == 7:
message.delete()
mutetime = extract_time(message, value)
bot.restrict_chat_member(chat.id, user.id, until_date=mutetime, can_send_messages=False)
bot.sendMessage(chat.id, tl(update.effective_message, "{} di bisukan selama {} karena menggunakan stiker '{}' yang ada di daftar hitam stiker").format(mention_markdown(user.id, user.first_name), value, trigger), parse_mode="markdown")
return
except BadRequest as excp:
if excp.message == "Message to delete not found":
pass
else:
LOGGER.exception("Error while deleting blacklist message.")
break