當前位置: 首頁>>代碼示例>>Python>>正文


Python Filters.photo方法代碼示例

本文整理匯總了Python中telegram.ext.Filters.photo方法的典型用法代碼示例。如果您正苦於以下問題:Python Filters.photo方法的具體用法?Python Filters.photo怎麽用?Python Filters.photo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在telegram.ext.Filters的用法示例。


在下文中一共展示了Filters.photo方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _group_hook

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [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 photo [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 photo [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: photo

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [as 別名]
def photo(bot, update):
  chat_id = get_chat_id(update)
  chat = TBDB.get_chat_entry(chat_id)
  if chat["qr_enabled"] == 0 and chat["photos_enabled"] == 0:
    return

  message = update.message or update.channel_post

  if message.photo:
    TranscriberBot.get().photos_thread_pool.submit(
      process_media_photo, bot, update, message.photo, chat
    ) 
開發者ID:charslab,項目名稱:TranscriberBot,代碼行數:14,代碼來源:handlers_messages.py

示例5: photo_filter_callback

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [as 別名]
def photo_filter_callback(bot, update):
	user_id = update.message.from_user.id
	lang_id = mysql_select_language(user_id)
	try:
		image = update.message.photo[-1]
		path = '{1}download/{0}.jpg'.format(image.file_id, qr_folder_path)
		#print(image)
		newFile = bot.getFile(image.file_id)
		newFile.download(path)
		qr = account_by_qr(path)
		account = qr[0]
		print(account)
		if ('xrb_' in account or 'nano_' in account):
			lang_keyboard(lang_id, bot, update.message.chat_id, lang_text('qr_send', lang_id).format(account))
			sleep(1)
			if (len(qr) > 1):
				send_destination(bot, update, account, True)
				sleep(0.3)
				print(qr[1])
				send_amount(bot, update, qr[1], True)
			else:
				send_destination(bot, update, account)
		elif (('NULL' in account) or (account is None) or (account is False)):
			lang_keyboard(lang_id, bot, update.message.chat_id, lang_text('qr_recognize_error', lang_id))
		else:
			lang_keyboard(lang_id, bot, update.message.chat_id, lang_text('qr_account_error', lang_id))
		#print(account)
		logging.info('QR by file: {0}'.format(account))
	except UnicodeEncodeError:
		lang_keyboard(lang_id, bot, update.message.chat_id, lang_text('text_decode_error', lang_id)) 
開發者ID:SergiySW,項目名稱:NanoWalletBot,代碼行數:32,代碼來源:raiwalletbot.py

示例6: start

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [as 別名]
def start(bot: Bot, update):
    update.message.reply_text(text="send a photo please")
    return PHOTO 
開發者ID:balemessenger,項目名稱:bale-bot-samples,代碼行數:5,代碼來源:send_photo.py

示例7: photo

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [as 別名]
def photo(bot, update):
    update.message.reply_photo(photo=update.message.photo[-1],
                               # photo="file_id",
                               # photo=open(file="file_path", mode='rb')
                               )
    return ConversationHandler.END 
開發者ID:balemessenger,項目名稱:bale-bot-samples,代碼行數:8,代碼來源:send_photo.py

示例8: build_lock_message

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [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

示例9: build_lock_message

# 需要導入模塊: from telegram.ext import Filters [as 別名]
# 或者: from telegram.ext.Filters import photo [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.photo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。