Exemple #1
0
class SingleIRCManager(IRCManager):
    def __init__(self, bot):
        super().__init__(bot)

        self.relay_host = bot.config['main'].get('relay_host')
        self.relay_password = bot.config['main'].get('relay_password')

        self.connection_manager = SingleConnectionManager(self.bot.reactor, self.relay_host, self.relay_password, self.username, self.password)

    def whisper(self, username, message):
        return self.connection_manager.whisper(username, message)

    def privmsg(self, message, channel, increase_message=True):
        return self.connection_manager.privmsg(channel, message)

    def _dispatcher(self, connection, event):
        method = getattr(self.bot, 'on_' + event.type, do_nothing)
        method(connection, event)

    def start(self):
        return self.connection_manager.start()

    def on_connect(self, sock):
        self.connection_manager.relay_connection.join(self.channel)
        if self.control_hub_channel:
            self.connection_manager.relay_connection.join(self.control_hub_channel)

    def on_disconnect(self, chatconn, event):
        log.error('Lost connection to relay')
        return self.connection_manager.on_disconnect()
Exemple #2
0
class SingleIRCManager(IRCManager):
    first_welcome = True

    def __init__(self, bot):
        super().__init__(bot)

        self.relay_host = bot.config['main'].get('relay_host')
        self.relay_password = bot.config['main'].get('relay_password')

        self.connection_manager = SingleConnectionManager(
            self.bot.reactor, self.relay_host, self.relay_password,
            self.username, self.password)

    def whisper(self, username, message):
        return self.connection_manager.whisper(username, message)

    def privmsg(self, message, channel, increase_message=True):
        return self.connection_manager.privmsg(channel, message)

    def _dispatcher(self, connection, event):
        method = getattr(self.bot, 'on_' + event.type, do_nothing)
        method(connection, event)

    def start(self):
        return self.connection_manager.start()

    def on_welcome(self, chatconn, event):
        if self.first_welcome:
            self.first_welcome = False
            welcome = '{nickname} {version} running!'
            phrase_data = {
                'nickname': self.bot.nickname,
                'version': self.bot.version,
            }

            self.bot.say(welcome.format(**phrase_data))

    def on_connect(self, sock):
        self.connection_manager.relay_connection.join(self.channel)
        if self.control_hub_channel:
            self.connection_manager.relay_connection.join(
                self.control_hub_channel)

    def on_disconnect(self, chatconn, event):
        log.error('Lost connection to relay')
        return self.connection_manager.on_disconnect()
Exemple #3
0
class SingleIRCManager(IRCManager):
    first_welcome = True

    def __init__(self, bot):
        super().__init__(bot)

        self.relay_host = bot.config['main'].get('relay_host')
        self.relay_password = bot.config['main'].get('relay_password')

        self.connection_manager = SingleConnectionManager(self.bot.reactor, self.relay_host, self.relay_password, self.username, self.password)

    def whisper(self, username, message):
        return self.connection_manager.whisper(username, message)

    def privmsg(self, message, channel, increase_message=True):
        return self.connection_manager.privmsg(channel, message)

    def _dispatcher(self, connection, event):
        method = getattr(self.bot, 'on_' + event.type, do_nothing)
        method(connection, event)

    def start(self):
        return self.connection_manager.start()

    def on_welcome(self, chatconn, event):
        if self.first_welcome:
            self.first_welcome = False
            phrase_data = {
                'nickname': self.bot.nickname,
                'version': self.bot.version,
                 }

            for p in self.bot.phrases['welcome']:
                self.bot.privmsg(p.format(**phrase_data))

    def on_connect(self, sock):
        self.connection_manager.relay_connection.join(self.channel)
        if self.control_hub_channel:
            self.connection_manager.relay_connection.join(self.control_hub_channel)

    def on_disconnect(self, chatconn, event):
        log.error('Lost connection to relay')
        return self.connection_manager.on_disconnect()
Exemple #4
0
class SingleIRCManager(IRCManager):
    first_welcome = True

    def __init__(self, bot):
        super().__init__(bot)

        self.relay_host = bot.config["main"].get("relay_host")
        self.relay_password = bot.config["main"].get("relay_password")

        self.connection_manager = SingleConnectionManager(
            self.bot.reactor, self.relay_host, self.relay_password, self.username, self.password
        )

    def whisper(self, username, message):
        return self.connection_manager.whisper(username, message)

    def privmsg(self, message, channel, increase_message=True):
        return self.connection_manager.privmsg(channel, message)

    def _dispatcher(self, connection, event):
        method = getattr(self.bot, "on_" + event.type, do_nothing)
        method(connection, event)

    def start(self):
        return self.connection_manager.start()

    def on_welcome(self, chatconn, event):
        if self.first_welcome:
            self.first_welcome = False
            phrase_data = {"nickname": self.bot.nickname, "version": self.bot.version}

            for p in self.bot.phrases["welcome"]:
                if not self.bot.silent:
                    self.bot.privmsg(p.format(**phrase_data))

    def on_connect(self, sock):
        self.connection_manager.relay_connection.join(self.channel)
        if self.control_hub_channel:
            self.connection_manager.relay_connection.join(self.control_hub_channel)

    def on_disconnect(self, chatconn, event):
        log.error("Lost connection to relay")
        return self.connection_manager.on_disconnect()
Exemple #5
0
class SingleIRCManager(IRCManager):
    first_welcome = True

    def __init__(self, bot):
        super().__init__(bot)

        self.relay_host = bot.config["main"].get("relay_host")
        self.relay_password = bot.config["main"].get("relay_password")

        self.connection_manager = SingleConnectionManager(
            self.bot.reactor, self.relay_host, self.relay_password, self.username, self.password
        )

    def whisper(self, username, message):
        return self.connection_manager.whisper(username, message)

    def privmsg(self, message, channel, increase_message=True):
        return self.connection_manager.privmsg(channel, message)

    def _dispatcher(self, connection, event):
        method = getattr(self.bot, "on_" + event.type, do_nothing)
        method(connection, event)

    def start(self):
        return self.connection_manager.start()

    def on_welcome(self, chatconn, event):
        if self.first_welcome:
            self.first_welcome = False
            welcome = "{nickname} {version} running!"
            phrase_data = {"nickname": self.bot.nickname, "version": self.bot.version}

            self.bot.say(welcome.format(**phrase_data))

    def on_connect(self, sock):
        self.connection_manager.relay_connection.join(self.channel)
        if self.control_hub_channel:
            self.connection_manager.relay_connection.join(self.control_hub_channel)

    def on_disconnect(self, chatconn, event):
        log.error("Lost connection to relay")
        return self.connection_manager.on_disconnect()