Beispiel #1
0
    def __init__(self, bot_config):
        self.bot_config = bot_config

        setup_logging(loglevel="INFO", console_loglevel="DEBUG",
                      log_path_format="logs/botlogs/%Y/%m/%Y-%m-%d.log")

        self.log = logging.getLogger("bot")

        conninfo = self.bot_config["Connection Info"]
        self.networking = Networking(conninfo["host"], conninfo["port"],
                                     timeout=conninfo["timeout"],
                                     floodcontrol_mode="msg_count",

                                     floodcontrol_config={"burst_count_per_10_seconds": 5,
                                                          "base_delay": 0.5,
                                                          "max_delay": 2})

        msginfo = self.bot_config["Bot Options"]["Message Sending"]
        self.networking.set_wait_coefficient(base_delay=msginfo["minimum delay"],
                                             messages_per_minute=msginfo["messages per minute"],
                                             burst=msginfo["burst"])

        self.message_handler = MessageHandler()

        self.user_messages = UserMessages(self)
        self.server_info = ServerInformation(self)
        self.channel_manager = ChannelManager(self)

        self.tools = Tools()

        self.log.info("All modules configured and set up. Bot is ready to go.")

        self._shutdown = False
Beispiel #2
0
    def __init__(self, parent, args):
        QtCore.QThread.__init__(self, parent)
        self._running = False
        self.args = args
        self.settings = Settings()
        self.net = Networking(self)
        BufferUtils.set_app(self)
        self.scene = Scene(self)
        self.plugins = PluginLoader()
        self.mixer = Mixer(self)
        self.playlist = Playlist(self)
        self.qt_app = parent

        self.scene.warmup()

        self.aubio_connector = None
        if not self.args.noaudio:
            self.aubio_thread = QtCore.QThread()
            self.aubio_thread.start()
            self.aubio_connector = AubioConnector()
            self.aubio_connector.onset_detected.connect(
                self.mixer.onset_detected)
            self.aubio_connector.fft_data.connect(
                self.mixer.audio.update_fft_data)
            self.aubio_connector.pitch_data.connect(
                self.mixer.audio.update_pitch_data)
            self.aubio_connector.moveToThread(self.aubio_thread)

        self.mixer.set_playlist(self.playlist)

        if self.args.preset:
            log.info("Setting constant preset %s" % args.preset)
            self.mixer.set_constant_preset(args.preset)
Beispiel #3
0
    def __init__(self, args, parent=None):
        self._running = False
        self.args = args
        self.settings = Settings()
        self.net = Networking(self)
        BufferUtils.set_app(self)
        self.scene = Scene(self)
        self.plugins = PluginLoader()
        self.mixer = Mixer(self)

        # Create the default layer.
        default_playlist = Playlist(self, self.args.playlist, 'last_playlist')
        default_layer = Layer(self, 'default')
        default_layer.set_playlist(default_playlist)
        self.mixer.add_layer(default_layer)

        if self.args.speech_layer:
            speech_playlist = Playlist(self, self.args.speech_playlist,
                                       'last_speech_playlist')
            speech_layer = Layer(self, 'speech')
            speech_layer.set_playlist(speech_playlist)
            self.mixer.add_layer(speech_layer)

        self.scene.warmup()

        self.aubio_connector = None
        if not self.args.noaudio:
            self.aubio_connector = AubioConnector()
            self.aubio_connector.onset_detected.connect(
                self.mixer.onset_detected)

        self.osc_server = None
        if not self.args.noosc:
            self.osc_server = OscServer(self.args.osc_port,
                                        self.args.mixxx_osc_port, self.mixer)
            self.osc_server.start()

        if self.args.preset:
            log.info("Setting constant preset %s" % args.preset)
            self.mixer.set_constant_preset(args.preset)

        QtCore.QThread.__init__(self, parent)
Beispiel #4
0
    def __init__(self, parent, args):
        QtCore.QThread.__init__(self, parent)
        self._running = False
        self.args = args
        self.settings = Settings()
        self.net = Networking(self)
        BufferUtils.set_app(self)
        self.scene = Scene(self)
        self.plugins = PluginLoader()
        self.mixer = Mixer(self)
        self.playlist = Playlist(self)
        self.qt_app = parent
        self.gui = None

        self.scene.warmup()

        self.mixer.set_playlist(self.playlist)

        if self.args.preset:
            log.info("Setting constant preset %s" % args.preset)
            self.mixer.set_constant_preset(args.preset)
Beispiel #5
0
    def __init__(self, args, parent=None):
        self._running = False
        self.args = args
        self.settings = Settings()
        self.net = Networking(self)
        self.scene = Scene(SceneLoader(self))
        self.plugins = PluginLoader()
        self.mixer = Mixer(self)
        self.playlist = Playlist(self)

        self.aubio_connector = None
        if self.args.audio:
            self.aubio_connector = AubioConnector()
            self.aubio_connector.onset_detected.connect(self.mixer.onset_detected)

        self.mixer.set_playlist(self.playlist)

        if self.args.preset:
            log.info("Setting constant preset %s" % args.preset)
            self.mixer.set_constant_preset(args.preset)

        QtCore.QThread.__init__(self, parent)
Beispiel #6
0
class IRCBot(object):
    def __init__(self, bot_config):
        self.bot_config = bot_config

        setup_logging(loglevel="INFO", console_loglevel="DEBUG",
                      log_path_format="logs/botlogs/%Y/%m/%Y-%m-%d.log")

        self.log = logging.getLogger("bot")

        conninfo = self.bot_config["Connection Info"]
        self.networking = Networking(conninfo["host"], conninfo["port"],
                                     timeout=conninfo["timeout"],
                                     floodcontrol_mode="msg_count",

                                     floodcontrol_config={"burst_count_per_10_seconds": 5,
                                                          "base_delay": 0.5,
                                                          "max_delay": 2})

        msginfo = self.bot_config["Bot Options"]["Message Sending"]
        self.networking.set_wait_coefficient(base_delay=msginfo["minimum delay"],
                                             messages_per_minute=msginfo["messages per minute"],
                                             burst=msginfo["burst"])

        self.message_handler = MessageHandler()

        self.user_messages = UserMessages(self)
        self.server_info = ServerInformation(self)
        self.channel_manager = ChannelManager(self)

        self.tools = Tools()

        self.log.info("All modules configured and set up. Bot is ready to go.")

        self._shutdown = False

    def start(self):
        userinfo = self.bot_config["User Info"]
        conninfo = self.bot_config["Connection Info"]

        self.networking.start_threads()

        self.networking.send_msg("PASS", [userinfo["password"]])
        self.networking.send_msg("NICK", [userinfo["name"]])
        self.networking.send_msg("USER", [userinfo["ident"], "*", "*"], userinfo["realname"])

        self.log.info("User info sent to server. Bot name: %s, identity: %s, real name: %s",
                      userinfo["name"], userinfo["ident"], userinfo["realname"])
        self.log.info("Listening for incoming messages now.")

        last_ping = time.time()

        while not self._shutdown:
            msg = self.networking.read_msg()
            if msg is None:
                time.sleep(0.1)
            else:
                pref, cmd, args, text = msg
                #print(msg)
                if cmd == "PING":
                    self.networking.send_msg("PONG", message=text)

                if self.message_handler.has_handler(cmd):
                    self.message_handler.execute_handler(cmd,
                                                         self, cmd, pref, args, text)

                if cmd == "376":
                    #self.irc_networking.send_msg("JOIN", self.bot_config["Connection Info"]["channels"])
                    #self.log.info("Joining channels: %s",
                    #              ", ".join(self.bot_config["Connection Info"]["channels"]))
                    #self.channel_manager.join_channel(*[("#"+"a"*40+str(x)) for x in range(25)])
                    self.channel_manager.join_channel(*self.bot_config["Connection Info"]["channels"])
            """
            if (time.time() - last_ping) > 30:
                IRCNetworking.send_msg("PING", [host])
                last_ping = time.time()
            """
            if self.networking.thread_has_crashed:
                self.shutdown_bot()

    def shutdown_bot(self):
        self.networking.send_msg("QUIT", ["Test"])#message="Shutting down")
        self._shutdown = True