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


Python Bot.say方法代码示例

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


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

示例1: __init__

# 需要导入模块: from bot import Bot [as 别名]
# 或者: from bot.Bot import say [as 别名]
class Main:

    def __init__(self):

        self.bot = Bot()
        self.q = self.bot.q
        self.raffle = {}
        self.bot.raffle = self.raffle
        self.bot.conn()
        Thread(target=self.read).start()

    def getUser(self, line):
        seperate = line.split(":", 2)
        user = seperate[1].split("!", 1)[0]
        return user

    def getMessage(self, line):
        separate = line.split(":", 2)
        message = separate[2]
        return message

    def getChannel(self, line):
        seperate = line.split("#", 1)
        channel = seperate[1].split(" ")[0]
        return channel

    def reset_raffle(self, msg, channel):
        try:
            s = int(msg.split(" in ")[1].split(" ")[0])
            if s > 6:
                time.sleep(s / 4 - 1)
            self.raffle[channel] = True
            time.sleep(2)
            self.raffle[channel] = False
        except:
            self.raffle[channel] = False

    def checkForRaffle(self, msg, channel):
        try:
            tempmsg = msg.split(" ")
            for i in range(len(tempmsg)):
                if "points" in tempmsg[i]:
                    points = tempmsg[i - 1]

            if "-" not in points:
                self.raffle[channel] = True
                Thread(target=self.reset_raffle, args=((msg, channel))).start()
                print("joining")
            else:
                print("negative raffle")
        except:
            print("invalid raffle")




    def read(self):

        while True:
            line = self.q.get()

            if "PRIVMSG" in line:
                user = self.getUser(line)
                msg = self.getMessage(line)
                channel = self.getChannel(line)

                try:
                    if user in BOTNAMES:
                        print("%s # %s : %s" % (channel, user, msg))
                        sys.stdout.flush()


                    if "aff" in msg.lower() and " begun " in msg.lower():
                        self.checkForRaffle(msg, channel)

                    if "aff" in msg.lower() and " ends in " in msg.lower() and self.raffle[channel]:
                        self.bot.say("!join " + random.choice(EMOTES), channel)
                        self.raffle[channel] = False

                except:
                    pass

                if user == "twitchnotify" and " to " not in msg:
                    self.bot.say("!join " + random.choice(EMOTES), channel)

            else:
                print(line)
开发者ID:nuuls,项目名称:old_rafflebot,代码行数:89,代码来源:run.py


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