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


Python TelegramBot.send_sticker方法代碼示例

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


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

示例1: DigestBot

# 需要導入模塊: from twx.botapi import TelegramBot [as 別名]
# 或者: from twx.botapi.TelegramBot import send_sticker [as 別名]

#.........這裏部分代碼省略.........
                try:
                    self.bot.send_message(chat.id, bot_answer)
                except Exception:
                    self.bot.send_message(chat.id, 'Unknow error. Sorry.')
            #Parse strory from bach.org rss and print in chat
            if Bash in text:
                d = feedparser.parse('http://bash.im/rss/')
                bot_answer =d['entries'][0]['title']+" "+d.entries[0]['link']
                try:
                    self.bot.send_message(chat.id, bot_answer)
                except Exception:
                    self.bot.send_message(chat.id, 'Unknow error. Sorry.')
            #Select random slogan from file "pogovorki.txt" and send in chat
            if Slogan in text:
                fp = open("pogovorki.txt")
                lines = fp.readlines()
                fp.close()
                phrase = ["Как говорил мой дед: ",
                          "Как говорят у нас в народе: ",
                          "Народная мудрость: ",
                          "Как мы все знаем: "]
                a = random.randrange(0,4,1)
                i = random.randrange(0,1353,1)
                slogan = (lines[i].strip())
                bot_answer = phrase[a] + slogan
                try:
                    self.bot.send_message(chat.id, bot_answer)
                except Exception:
                    self.bot.send_message(chat.id, 'Unknow error. Sorry.')
            #Send strickers in chat
            if (text == Sticker):
                stikers = ["BQADAgADeAcAAlOx9wOjY2jpAAHq9DUC"]
                try:
                    self.bot.send_sticker(chat.id, stikers[0])
                except Exception:
                    self.bot.send_photo(chat.id, 'Unknow error. Sorry.')
            #Send photo from /photo path
            if (text == Photo):
                photos = ["photo/photo1.jpg"]
                          #"photo/photo2.jpg",
                          #"photo/photo3.jpg"]
                #i = random.randrange(0,3,1)
                fp = open(photos[0], "rb")
                file_info = InputFileInfo(photos[0], fp, 'image/jpg')
                a = InputFile('photo', file_info)
                self.bot.send_photo(chat.id, a)
                fp.close()
            #Send comment from Toxa.txt file
            if Toxa in text:
                fp = open("Toxa.txt")
                lines = fp.readlines()
                fp.close()
                i = random.randrange(0,len(lines)-1,1)
                slogan = (lines[i].strip())
                bot_answer = slogan + '\n'
                try:
                    self.bot.send_message(chat.id, bot_answer)
                except Exception:
                    self.bot.send_message(chat.id, 'Unknow error. Sorry.')
            #Send comment from Zaur.txt file
            if Zaur in text:
                fp = open("Zaur.txt")
                lines = fp.readlines()
                fp.close()
                i = random.randrange(0,len(lines)-1,1)
                slogan = (lines[i].strip())
開發者ID:pablozzz,項目名稱:zaurtox_bot,代碼行數:70,代碼來源:ZaurTox.py


注:本文中的twx.botapi.TelegramBot.send_sticker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。