当前位置: 首页>>代码示例>>Python>>正文


Python Filters.location方法代码示例

本文整理汇总了Python中telegram.ext.Filters.location方法的典型用法代码示例。如果您正苦于以下问题:Python Filters.location方法的具体用法?Python Filters.location怎么用?Python Filters.location使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在telegram.ext.Filters的用法示例。


在下文中一共展示了Filters.location方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _group_hook

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [as 别名]
def _group_hook(self):
        # noinspection PyUnusedLocal
        def hook(update, context):
            msg = update.effective_message
            if msg.group_chat_created:
                self.bus.post(GroupChatCreatedEvent(chat_id=update.effective_chat.id,
                                                    message=self._plugin.parse_msg(msg).output,
                                                    user=self._plugin.parse_user(update.effective_user).output))
            elif msg.photo:
                self._msg_hook(PhotoMessageEvent)(update, context)
            elif msg.video:
                self._msg_hook(VideoMessageEvent)(update, context)
            elif msg.contact:
                self._msg_hook(ContactMessageEvent)(update, context)
            elif msg.location:
                self._msg_hook(LocationMessageEvent)(update, context)
            elif msg.document:
                self._msg_hook(DocumentMessageEvent)(update, context)
            elif msg.text:
                if msg.text.startswith('/'):
                    self._command_hook()(update, context)
                else:
                    self._msg_hook(TextMessageEvent)(update, context)

        return hook 
开发者ID:BlackLight,项目名称:platypush,代码行数:27,代码来源:telegram.py

示例2: run

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [as 别名]
def run(self):
        # noinspection PyPackageRequirements
        from telegram.ext import MessageHandler, Filters

        super().run()
        telegram = self._plugin.get_telegram()
        dispatcher = telegram.dispatcher

        dispatcher.add_handler(MessageHandler(Filters.group, self._group_hook()))
        dispatcher.add_handler(MessageHandler(Filters.text, self._msg_hook(TextMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.photo, self._msg_hook(PhotoMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.video, self._msg_hook(VideoMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.contact, self._msg_hook(ContactMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.location, self._msg_hook(LocationMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.document, self._msg_hook(DocumentMessageEvent)))
        dispatcher.add_handler(MessageHandler(Filters.command, self._command_hook()))

        self.logger.info('Initialized Telegram backend')
        telegram.start_polling()


# vim:sw=4:ts=4:et: 
开发者ID:BlackLight,项目名称:platypush,代码行数:24,代码来源:telegram.py

示例3: build_lock_message

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [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 
开发者ID:skittles9823,项目名称:SkittBot,代码行数:34,代码来源:locks.py

示例4: location

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [as 别名]
def location(bot, update):
    user = update.message.from_user
    user_location = update.message.location
    logger.info("Location of {}: ({}, {})".format(
                user.first_name, user_location.latitude,
                user_location.longitude))
    report_map = geo_app()
    report_map.append_data(user_location.latitude, user_location.longitude)
    update.message.reply_text(loc_aquired[LANG])
    bot.send_message(chat_id=update.message.chat_id, text=back2menu[LANG])
    return MENU 
开发者ID:RodolfoFerro,项目名称:DisAtBot,代码行数:13,代码来源:DisAtBot.py

示例5: build_lock_message

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [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 
开发者ID:TGExplore,项目名称:Marie-2.0-English,代码行数:33,代码来源:locks.py

示例6: main

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [as 别名]
def main():
    """
    Main function.
    This function handles the conversation flow by setting
    states on each step of the flow. Each state has its own
    handler for the interaction with the user.
    """
    global LANG
    # Create the EventHandler and pass it your bot's token.
    updater = Updater(telegram_token)

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

    # Add conversation handler with predefined states:
    conv_handler = ConversationHandler(
        entry_points=[CommandHandler('start', start)],

        states={
            SET_LANG: [RegexHandler('^(ES|EN)$', set_lang)],

            MENU: [CommandHandler('menu', menu)],

            SET_STAT: [RegexHandler(
                        '^({}|{}|{}|{})$'.format(
                            send_report['ES'], view_map['ES'],
                            view_faq['ES'], view_about['ES']),
                        set_state),
                       RegexHandler(
                        '^({}|{}|{}|{})$'.format(
                            send_report['EN'], view_map['EN'],
                            view_faq['EN'], view_about['EN']),
                        set_state)],

            LOCATION: [MessageHandler(Filters.location, location),
                       CommandHandler('menu', menu)]
        },

        fallbacks=[CommandHandler('cancel', cancel),
                   CommandHandler('help', help)]
    )

    dp.add_handler(conv_handler)

    # Log all errors:
    dp.add_error_handler(error)

    # Start DisAtBot:
    updater.start_polling()

    # Run the bot until the user presses Ctrl-C or the process
    # receives SIGINT, SIGTERM or SIGABRT:
    updater.idle() 
开发者ID:RodolfoFerro,项目名称:DisAtBot,代码行数:55,代码来源:DisAtBot.py

示例7: build_lock_message

# 需要导入模块: from telegram.ext import Filters [as 别名]
# 或者: from telegram.ext.Filters import location [as 别名]
def build_lock_message(chat_id):
	locks = sql.get_locks(chat_id)
	res = ""
	locklist = []
	permslist = []
	if locks:
		res += "*" + tl(chat_id, "Ini adalah kunci dalam obrolan ini:") + "*"
		if locks:
			locklist.append("sticker = `{}`".format(locks.sticker))
			locklist.append("audio = `{}`".format(locks.audio))
			locklist.append("voice = `{}`".format(locks.voice))
			locklist.append("document = `{}`".format(locks.document))
			locklist.append("video = `{}`".format(locks.video))
			locklist.append("contact = `{}`".format(locks.contact))
			locklist.append("photo = `{}`".format(locks.photo))
			locklist.append("gif = `{}`".format(locks.gif))
			locklist.append("url = `{}`".format(locks.url))
			locklist.append("bots = `{}`".format(locks.bots))
			locklist.append("forward = `{}`".format(locks.forward))
			locklist.append("game = `{}`".format(locks.game))
			locklist.append("location = `{}`".format(locks.location))
			locklist.append("rtl = `{}`".format(locks.rtl))
			locklist.append("button = `{}`".format(locks.button))
	permissions = dispatcher.bot.get_chat(chat_id).permissions
	permslist.append("messages = `{}`".format(permissions.can_send_messages))
	permslist.append("media = `{}`".format(permissions.can_send_media_messages))
	permslist.append("poll = `{}`".format(permissions.can_send_polls))
	permslist.append("other = `{}`".format(permissions.can_send_other_messages))
	permslist.append("previews = `{}`".format(permissions.can_add_web_page_previews))
	permslist.append("info = `{}`".format(permissions.can_change_info))
	permslist.append("invite = `{}`".format(permissions.can_invite_users))
	permslist.append("pin = `{}`".format(permissions.can_pin_messages))

	if locklist:
		# Ordering lock list
		locklist.sort()
		# Building lock list string
		for x in locklist:
			res += "\n - {}".format(x)
	res += "\n\n*" + tl(chat_id, "Ini adalah izin dalam obrolan ini:") + "*"
	for x in permslist:
		res += "\n - {}".format(x)
	return res 
开发者ID:AyraHikari,项目名称:EmiliaHikari,代码行数:45,代码来源:locks.py


注:本文中的telegram.ext.Filters.location方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。