Python telegram.ext.Filters 模块,sticker() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用telegram.ext.Filters.sticker()

项目:TBot8-1    作者:Danzilla-cool    | 项目源码 | 文件源码
def text_echo(bot, update):
    chat_id = update.message.chat_id
    mess = update.message.text
    for hi in greetings:
        if len(mess) >= len(hi) and mess.lower()[:len(hi)] == hi:
            if update.message.from_user.id == id.MY_ID:
                sticker = el_stickers[random.randint(0, len(el_stickers) - 1)]
                bot.sendMessage(chat_id, text='??????????, ????????? ' + evil_em)
                bot.sendSticker(chat_id, sticker)

            else:
                sticker = stickers[random.randint(0, len(stickers) - 1)]
                bot.sendMessage(chat_id, text='??? ??????, ' + update.message.from_user.first_name)
                bot.sendSticker(chat_id, sticker)
            break
    if "?? ???" in mess.lower() or "?? ???" in mess.lower():
        sticker = "BQADBQADDAEAAukKyANFGtSvd3H9ngI"
        bot.sendSticker(chat_id, sticker)
项目:tgbot    作者:PaulSonOfLars    | 项目源码 | 文件源码
def warn(user_id, chat, reason, bot, message):
    if is_user_admin(chat, user_id):
        message.reply_text("Damn admins, can't even be warned!")
        return

    user_warned = sql.warn_user(user_id, chat.id, reason)
    if user_warned.num_warns >= 3:
        res = chat.kick_member(user_id)
        if res:
            bot.send_sticker(chat.id, 'CAADAgADOwADPPEcAXkko5EB3YGYAg')  # banhammer marie sticker
            message.reply_text("3 warnings, this user has been banned!")
            sql.reset_warns(user_id, chat.id)
        else:
            message.reply_text("An error occurred, I couldn't ban this person!")
    else:
        keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user_id))]])
        if reason:
            message.reply_text("{}/3 warnings... watch out! Latest one was because:\n{}".format(user_warned.num_warns, reason), reply_markup=keyboard)
        else:
            message.reply_text("{}/3 warnings... watch out!".format(user_warned.num_warns), reply_markup=keyboard)
项目:coolq-telegram-bot    作者:jqqqqqqqqqq    | 项目源码 | 文件源码
def sticker_from_telegram(bot: telegram.Bot, update: telegram.Update):

    message: telegram.Message = update.message

    tg_group_id = message.chat_id  # telegram group id
    forward_index = get_forward_index(tg_group_id=tg_group_id)

    reply_entity = list()

    file_id = update.message.sticker.file_id
    if JQ_MODE:
        tg_get_pic_url(file_id, 'png')
        reply_entity.append({
            'type': 'image',
            'data': {'file': file_id + '.png'}
        })
    elif IMAGE_LINK_MODE[forward_index]:
        pic_url = tg_get_pic_url(file_id, 'png')
        reply_entity.append({
            'type': 'text',
            'data': {'text': '[ ' + message.sticker.emoji + ' sticker, ?????' + pic_url + ' ]'}
        })
    else:
        reply_entity.append({
            'type': 'text',
            'data': {'text': '[ ' + message.sticker.emoji + ' sticker ]'}
        })
    qq_message_id = send_from_tg_to_qq(forward_index,
                                       message=reply_entity,
                                       tg_group_id=tg_group_id,
                                       tg_user=message.from_user,
                                       tg_forward_from=message,
                                       tg_reply_to=message.reply_to_message)
    global_vars.mdb.append_message(qq_message_id, message.message_id, forward_index, 0)
项目:JackOfAllGroups-telegram-bot    作者:Kyraminol    | 项目源码 | 文件源码
def send_media(bot, chat_id, media_type, media_id, text, reply_to_id=None):
    if media_type == "audio":
        bot.send_audio(chat_id=chat_id, audio=media_id, reply_to_message_id=reply_to_id)
    elif media_type == "document":
        bot.send_document(chat_id=chat_id, document=media_id, caption=text, reply_to_message_id=reply_to_id)
    elif media_type == "photo":
        bot.send_photo(chat_id=chat_id, photo=media_id, caption=text, reply_to_message_id=reply_to_id)
    elif media_type == "sticker":
        bot.send_sticker(chat_id=chat_id, sticker=media_id, reply_to_message_id=reply_to_id)
    elif media_type == "video":
        bot.send_video(chat_id=chat_id, video=media_id, caption=text, reply_to_message_id=reply_to_id)
    elif media_type == "voice":
        bot.send_voice(chat_id=chat_id, voice=media_id, reply_to_message_id=reply_to_id)
项目:JackOfAllGroups-telegram-bot    作者:Kyraminol    | 项目源码 | 文件源码
def main():
    updater = Updater("INSERT TOKEN HERE")
    dp = updater.dispatcher
    dp.add_handler(CommandHandler("start", cmd_start))
    dp.add_handler(CommandHandler("md", cmd_markdown, allow_edited=True))
    dp.add_handler(CommandHandler("markdown", cmd_markdown, allow_edited=True))
    dp.add_handler(CommandHandler("pin", cmd_pin, allow_edited=True))
    dp.add_handler(CommandHandler("welcome", cmd_welcome, allow_edited=True))
    dp.add_handler(CommandHandler("goodbye", cmd_goodbye, allow_edited=True))
    dp.add_handler(CommandHandler("del_welcome", cmd_clear_welcome))
    dp.add_handler(CommandHandler("del_goodbye", cmd_clear_goodbye))
    dp.add_handler(CommandHandler("set_bot_admin", cmd_set_bot_admin, allow_edited=True))
    dp.add_handler(CommandHandler("remove_bot_admin", cmd_remove_bot_admin, allow_edited=True))
    dp.add_handler(CommandHandler("settings", cmd_settings))
    dp.add_handler(CommandHandler("shortcut", cmd_shortcut_set, allow_edited=True))
    dp.add_handler(CommandHandler("del_shortcut", cmd_shortcut_del, allow_edited=True))
    dp.add_handler(CommandHandler("shortcuts", cmd_shortcut_getall, allow_edited=True))
    dp.add_handler(MessageHandler(Filters.audio |
                                  Filters.command |
                                  Filters.contact |
                                  Filters.document |
                                  Filters.photo |
                                  Filters.sticker |
                                  Filters.text |
                                  Filters.video |
                                  Filters.voice |
                                  Filters.status_update, msg_parse, allow_edited=True))
    dp.add_handler(CallbackQueryHandler(inline_button_callback))
    dp.add_error_handler(error)
    updater.start_polling()
    updater.idle()
项目:TBot8-1    作者:Danzilla-cool    | 项目源码 | 文件源码
def meat(bot, update):
    chat_id = update.message.chat_id
    sticker = "BQADAgADCgADe20bDCFnxX39AzsdAg"
    bot.sendSticker(chat_id, sticker)
项目:TBot8-1    作者:Danzilla-cool    | 项目源码 | 文件源码
def sticker_echo(bot, update):
    chat_id = update.message.chat_id
    if update.message.chat.id == id.MY_ID:
        bot.sendMessage(chat_id, text="???????? ????? ???????:")
        bot.sendMessage(chat_id, text=update.message.sticker.file_id)
项目:TBot8-1    作者:Danzilla-cool    | 项目源码 | 文件源码
def main():

    token = open("token.txt", "r")
    token_name = token.readline()
    token.close()
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(token_name)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher


    # on different commands - answer in Telegram
    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))
    dp.add_handler(CommandHandler("timet", get_timetable, pass_args=True))
    dp.add_handler(CommandHandler("set", set, pass_args=True, pass_job_queue=True))
    dp.add_handler(CommandHandler("unset", unset, pass_job_queue=True))
    dp.add_handler(CommandHandler("mates", get_mates))
    dp.add_handler(CommandHandler("????", meat))
    dp.add_handler(CommandHandler("spam", spam, pass_args=True))

    # on noncommand i.e message - echo the message on Telegram
    dp.add_handler(MessageHandler([Filters.text], text_echo))
    dp.add_handler(MessageHandler([Filters.sticker], sticker_echo))

    # log all errors
    dp.add_error_handler(error)

    # Start the Bot
    updater.start_polling()

    # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
    # SIGTERM or SIGABRT. This should be used most of the time, since
    # start_polling() is non-blocking and will stop the bot gracefully.
    updater.idle()
项目:tgbot    作者:PaulSonOfLars    | 项目源码 | 文件源码
def filters(bot, update):
    chat = update.effective_chat
    msg = update.effective_message
    args = msg.text.split(None, 2)  # use python's maxsplit to separate Cmd, keyword, and reply_text

    keyword = args[1]
    is_sticker = False
    is_document = False

    if len(args) >= 3:
        content = args[2]

    elif msg.reply_to_message and msg.reply_to_message.sticker:
        content = msg.reply_to_message.sticker.file_id
        is_sticker = True

    elif msg.reply_to_message and msg.reply_to_message.document:
        content = msg.reply_to_message.document.file_id
        is_document = True

    else:
        return

    save_filter(chat.id, keyword, content, is_sticker, is_document)
    update.effective_message.reply_text("Handler {} added!".format(keyword))
    raise DispatcherHandlerStop
项目:tgbot    作者:PaulSonOfLars    | 项目源码 | 文件源码
def del_sticker(bot, update):
    chat = update.effective_chat
    if sql.is_locked(chat.id, "sticker") and can_delete(chat, bot.id):
        update.effective_message.delete()
项目:TelegramBots    作者:d-qoi    | 项目源码 | 文件源码
def main():
    global mClient, mDatabase

    mClient = MongoClient(mongoURI)
    mDatabase = mClient[mDatabase]


    try:
        serverInfo = mClient.server_info()
        logger.info("Mongo Connection Achieved")
        logger.debug("Connected to Mongo Server: %s" % serverInfo)
    except:
        logger.error("Could not connect to Mongo Server at %s" % mongoURI)
        raise

    updater = Updater(authToken)

    dp = updater.dispatcher

    dp.add_handler(CommandHandler("start", start))
    dp.add_handler(CommandHandler("help", help))

    charCreationHandler = ConversationHandler(
        entry_points=[CommandHandler('meAbout',meAbout, pass_user_data=True)],
        states={
                TEXTRESP:[MessageHandler(Filters.text, meTextResp, pass_user_data=True),
                          MessageHandler(Filters.all, redoState, pass_user_data=True)],
                PHOTORESP:[MessageHandler(Filters.photo or Filters.sticker, mePhotoResp, pass_user_data=True),
                           MessageHandler(Filters.all, redoState, pass_user_data=True)],
                CHOOSE:[RegexHandler("^(Name, Discription, Photo, Bio, Cancel)$", meChoose, pass_user_data=True)]
            },  
        fallbacks=[CommandHandler('cancel',meAboutCancel, pass_user_data=True)]                                                           
        )
    structCreationHandler = ConversationHandler(
        entry_points=[CommandHandler('newStruct', editStructStart, pass_user_data=True)],
        states={STRUCTNAME:[MessageHandler(Filters.text, editStructSetName, pass_user_data=True),
                      MessageHandler(Filters.all, redoState, pass_user_data=True)]
                STRUCTDESC:[MessageHandler(Filters.text, editStructSetDesc, pass_user_data=True),
                            MessageHandler(Filters.all, redoState, pass_user_data=True)],
                STRUCTDOOR:[MessageHandler(Filters.text, editStructSetDoor, pass_user_data=True),
                            MessageHandler(Filters.all, redoState, pass_user_data=True)]},
        fallbacks=[CommandHandler("cancel", cancel)])
    roomCreationHandler = ConversationHandler(
        entry_points=[ConversationHandler("editRoom", editRoomStart)],
        states={},
        fallbacks=[CommandHandler("cancel", cancel)])

    dp.add_handler(CommandHandler("roomAddObjDisc", roomAddObjDisc, allow_edited=True))
    dp.add_handler(CommandHandler("roomRemObjDisc", roomRemObjDisc))

    dp.add_handler(CommandHandler("roomAddTempDisc", roomAddTempDisc, allow_edited=True))
    dp.add_handler(CommandHandler("roomRemTempDisc", roomRemTempDisc))

    dp.add_handler(CommandHandler("doorLock",doorLock))
    dp.add_handler(CommandHandler("doorUnlock", doorUnlock))
    dp.add_handler(CommandHandler("doorKnock", doorKnock))

    updater.start_polling()
    updater.idle()

    mClient.close()