示例#1
0
    def VoteBanAsync(self, user):
        util.SendMessage(random.choice(self.beginResponses).format(user))
        time.sleep(1.800)
        util.SendMessage(f"{user} will be banned in 3...")
        time.sleep(0.680)
        util.SendMessage("2...")
        time.sleep(0.880)
        util.SendMessage("1...")
        time.sleep(1.080)
        util.SendMessage(f"/me {user} is cute and important and cannot be banned from this chat GivePLZ <3")

        self.threadRunning = False
        return
示例#2
0
    def EndPoll(self):
        with self.pollLock:
            if not self.pollRunning:
                return

            self.pollRunning = False

            if len(self.voters) == 0:
                response = "No one voted for the poll. :("
            else:
                winner = max(self.voteCollection, key=self.voteCollection.get)
                percent = round(self.voteCollection[winner] /
                                len(self.voters) * 100)
                response = f"Poll ended with {len(self.voters)} votes. "

                if self.voteCollection.keys() == {"y", "n"}:
                    response += "VoteYea " if winner == "y" else "VoteNay "
                else:
                    response += f"Option {winner.upper()} "

                response += f"wins with {percent}% of the vote"

            self.voteCollection = {}
            self.voters = []
            self.pollTimeout = 0

        util.SendMessage(response)
        return
示例#3
0
    def PollAsync(self):
        while self.pollTimeout >= 30:
            time.sleep(30)

            self.pollTimeout -= 30

            if (not self.pollRunning or self.pollTimeout < 30):
                break

            if self.pollTimeout % 60 == 0:
                minutes = int(self.pollTimeout / 60)

                minMsg = "minute" if minutes == 1 else "minutes"
                util.SendMessage(
                    f"Don't forget to vote. Only {minutes} {minMsg} remaining")

            elif self.pollTimeout == 30:
                util.SendMessage(f"Last chance to vote! Only 30 seconds left")

        self.EndPoll()
        return
示例#4
0
    def message_handler(self, m):
        # Check for proper message type
        if (m.type != "PRIVMSG" and m.type != "WHISPER"):
            return

        # Check for valid message with prefix and valid rewards
        validReward = "custom-reward-id" in m.tags
        validCommand = m.message != None and len(
            m.message) > 1 and m.message[0] in self.prefixes

        if (not validReward and not validCommand):
            return

        try:
            if validReward:
                util.LogReceived(m.type, m.user, m.message, m.tags)
                util.SendMessage(self.redeem[m.tags["custom-reward-id"]](m),
                                 m.type, m.user)

            if validCommand:
                # Retrieve first word without prefix
                m.message = m.message[1:]
                token = m.message.lower().split()[0]

                if (token in self.execute):
                    util.LogReceived(m.type, m.user, m.message, m.tags, True)
                    util.SendMessage(self.execute[token](m), m.type, m.user)
                    return

                # Simple response commands
                # Note that we don't get this far unless the message does not match other commands
                response = self.commands["CustomCommands"].Execute(m)
                if response != None:
                    util.SendMessage(response, m.type, m.user)
                    return

        except Exception as e:
            ptf(f"Error: {e}", time=True)