Esempio n. 1
0
            timer_expired = self.timer_man.getExpired()  # a timer expired
            # self.logger.info("tick")
            if timer_expired:
                # self.logger.info("timer expired")

                if timer_expired.data == 1:
                    # self.logger.info("1")
                    r = self._db.getResults()
                    if r:  # most of the time this will be None so check first
                        self.HandleResults(ssbot, event, r)
                    self.timer_man.set(1, 1)  # set it to check again in a sec
                elif timer_expired.data == 2:
                    # self.logger.info("2")
                    self._db.ping()
                    self.timer_man.set(300, 2)

    def HandleResults(self, ssbot, event, r):
        # message like connection error or connected
        if r.getType() == AElement.TYPE_MESSAGE:
            self.logger.info(r.message)
        else:
            r.GenericResultPrettyPrinter(
                ssbot, r.query.data[0], r.query.data[1])

    def cleanup(self):
        self._db.cleanUp()

# bot runs in this if not run by master u can ignore this
if __name__ == '__main__':
    bot_main(Bot, False, True, "#egfdl")
Esempio n. 2
0
        self.log_time = time.time()

    def handle_events(self, ssbot, event):
        if event.type == EVENT_COMMAND and event.command.id == self.cmd_id_log:
            self.log_player = event.player
            self._log_time = time.time() + 5
            ssbot.send_private_message(event.player, "ok")
            ssbot.send_public_message("*log")
        if (event.type == EVENT_MESSAGE
                and event.message_type == MESSAGE_TYPE_ARENA
                and self.log_player is not None):
            m = event.message
            if m.startswith(("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")):
                ssbot.send_private_message(self.log_player, m)
        if (event.type == EVENT_TICK and self.log_player is not None
                and self.log_time >= time.time()):
            self.log_player = None
        if (event.type == EVENT_LEAVE and event.player == self.log_player):
            self.log_player = None

    def cleanup(self):
        # put any cleanup code in here this is called when bot is about to die
        pass


if __name__ == '__main__':
    # bot runs in this if not run by master
    # generic main function for when you run bot in standalone mode
    # we pass in the Bot class to the function, so it can run it for us
    bot_main(Bot)
Esempio n. 3
0
                tb = "-" * (sum(map(int, lengths)) + (len(lengths) * 3) + 1)
                fm = "|"
                for col in lengths:  # make the format string
                    fm += " %" + str(col) + "s |"
                f.write(tb)
                f.write((fm % tuple(names)))
                f.write(tb)

                for row in self.rows:  # output the rows
                    f.write((fm % row))
                f.write(tb)
                f.close()

    def HandleResults(self, ssbot, event, r):
        # message like connection error or connected
        if r.getType() == AElement.TYPE_MESSAGE:
            self.logger.info(r.message)
        else:
            # if r.query.data[2] in self.cache:
            #     self.cache[r.query.data[2]] = (
            #       copy.copy(r), get_tick_count_hs())
            r.GenericResultPrettyPrinter(
                ssbot, r.query.data[0], r.query.data[1])

    def cleanup(self):
        self._db.CleanUp()

# bot runs in this if not run by master u can ignore this
if __name__ == '__main__':
    bot_main(Bot, False, True, "-")
Esempio n. 4
0
            elif event.command.id == self.cmdlt:
                ssbot.send_reply(event, "Current Setting:" + str(self.current))
                for t in self.tiers:
                    t.printReply(ssbot, event)
        elif event.type == EVENT_ENTER:
            if self.current:
                ssbot.send_private_message(
                    event.player,
                    "Current Setting:%s ::!lt for more details" % str(
                        self.current)
                )
        elif event.type == EVENT_TICK:
            timer_expired = self.tm.getExpired()
            if timer_expired:
                # timer_expired is now the data we passed to timer
                if timer_expired.data == 1:
                    self.doTransition(ssbot)
                    # changed by serexl on 12/15, originally
                    # self.tm.set(self.current.getNextTimerDelay(), 1)
                    self.tm.set(5 * 60, 1)

    def cleanup(self):
        # put any cleanup code in here this is called when bot is about to die
        pass

if __name__ == '__main__':
    # bot runs in this if not run by master
    # generic main function for when you run bot in standalone mode
    # we pass in the Bot class to the function, so it can run it for us
    bot_main(Bot, False, False, "#master")
Esempio n. 5
0
    def handle_events(self, ssbot, event):
        if event.type == EVENT_TICK:
            timer_expired = self.tm.getExpired()
            if timer_expired:
                # timer_expired is now the data we passed to timer
                if timer_expired.data == 1:
                            for bname, answered in \
                                    self.killable_bots.iteritems():
                                p = ssbot.find_player_by_name(bname)
                                if p:
                                    if answered:
                                        ssbot.send_private_message(p, "!wtf")
                                        self.bots_to_check[event.pname] = False
                                    else:
                                        ssbot.send_private_message(p, "*kill")
                                        ssbot.send_public_message(
                                            "?alert %s is not responding and"
                                            " has been killed" % bname
                                        )
                                        self.bots_to_check[event.pname] = True
                            self.tm.set(60, 1)
        elif event.type in [EVENT_COMMAND, EVENT_MESSAGE]:
            if event.pname in self.bots_to_check:
                self.bots_to_check[event.pname] = True

    def cleanup(self):
        pass

if __name__ == '__main__':
    bot_main(Bot, False, False, "99")
Esempio n. 6
0
                diff = v[0].symmetric_difference(v[1])
                # self.logger.info(v[0])
                # self.logger.info(v[1])
                # self.logger.info(diff)
                if len(diff) > 0:  # wtf list needs to be sent again
                    v[0].clear()
                    v[0] = v[1].copy()
                    s = "*s*peer" + str(k) + ":arenas:"
                    for a in v[0]:
                        s += a + ", "
                    # print s
                    if len(s) > 256:
                        self.logger.debug(
                            "peer" + str(k) + " string too big::" + s)
                        ssbot.send_public_message(s[0:255])
                    else:
                        ssbot.send_public_message(s)
                    # self.logger.info(s)
                # else:
                #    self.logger.info("no change in arenas")

                v[1].clear()  # set new list to Non

    def cleanup(self):
        # put any cleanup code in here this is called when bot is about to die
        pass


if __name__ == '__main__':
    bot_main(Bot)
Esempio n. 7
0
                fm = "|"
                for col in lengths:  # make the format string
                    fm += " %" + str(col) + "s |"
                f.write(tb)
                f.write((fm % tuple(names)))
                f.write(tb)

                for row in self.rows:  # output the rows
                    f.write((fm % row))
                f.write(tb)
                f.close()

    def HandleResults(self, ssbot, event, r):
        # message like connection error or connected
        if r.getType() == AElement.TYPE_MESSAGE:
            self.logger.info(r.message)
        else:
            # if r.query.data[2] in self.cache:
            #     self.cache[r.query.data[2]] = (
            #       copy.copy(r), get_tick_count_hs())
            r.GenericResultPrettyPrinter(ssbot, r.query.data[0],
                                         r.query.data[1])

    def cleanup(self):
        self._db.CleanUp()


# bot runs in this if not run by master u can ignore this
if __name__ == '__main__':
    bot_main(Bot, False, True, "-")
Esempio n. 8
0
                    # (qtype, message type to respond with,
                    # target[playername if priv msg)
                    qdata = (self.QTYPE_ADDPOP, MESSAGE_TYPE_PUBLIC, None)
                    db = self._db
                    db.query(query % qtp, None, qdata)
                    pass

    def HandleResults(self, ssbot, event, r):
        # message like connection error or connected
        if r.getType() == AElement.TYPE_MESSAGE:
            self.logger.info(r.message)
        else:
            if r.query.data[0] == self.QTYPE_SQL:
                r.GenericResultPrettyPrinter(
                    ssbot, r.query.data[1], r.query.data[2])
            if r.query.data[0] == self.QTYPE_SPG:
                self.ResultGraphPrinter(
                    r, ssbot, r.query.data[1], r.query.data[2])
            elif r.query.data[0] == self.QTYPE_ADDPOP:
                pass
                # spews to pub only if there is a failure
                r.GenericResultPrettyPrinter(
                    ssbot, r.query.data[1], r.query.data[2], True)

    def cleanup(self):
        self._db.cleanUp()

# bot runs in this if not run by master u can ignore this
if __name__ == '__main__':
    bot_main(Bot, False, True)