当前位置: 首页>>代码示例>>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;未经允许,请勿转载。