# Path: pyGBot/log.py
# def addScreenHandler(logobj, format):
# def addLogFileHandler(logobj, filename, format):
# 
# Path: pyGBot/core.py
# CHANNEL_PREFIXES = '&#!+'
# 
# Path: pyGBot/BasePlugin.py
# class BasePlugin:
#     def __init__(self, bot, options):
#         self.bot = bot
# 
#     def activate(self, channel=None):
#         """
#         Called when the plugin is activated.
#         """
#         return True
# 
#     def deactivate(self, channel=None):
#         """
#         Called when the plugin is deactivated.
#         """
#         return True
# 
#     # Event handlers for other users
#     def user_join(self, channel, username):
#         pass
# 
#     def user_part(self, channel, username):
#         pass
# 
#     def user_kicked(self, channel, username, kicker, message=""):
#         pass
# 
#     def user_quit(self, username, reason=""):
#         pass
# 
#     def user_nickchange(self, username, newname):
#         pass
# 
#     # Event handlers for this bot
#     def bot_connect(self):
#         pass
# 
#     def bot_join(self, channel):
#         pass
# 
#     def bot_part(self, channel):
#         pass
# 
#     def bot_kicked(self, channel, kicker="", reason=""):
#         pass
# 
#     def bot_disconnect(self):
#         pass
# 
# 
#     # Event handlers for incoming messages
#     def msg_channel(self, channel, user, message):
#         pass
# 
#     def msg_action(self, channel, user, message):
#         pass
# 
#     def msg_private(self, user, message):
#         pass
# 
#     def msg_notice(self, user, message):
#         pass
# 
#     # Event handlers for channel information replies
#     def channel_names(self, channel, nameslist):
#         pass
# 
#     def channel_topic(self, channel, user, topic):
#         pass
# 
#     # Other system event handlers
#     def timer_tick(self):
#         pass


from pyGBot import log
from pyGBot.core import CHANNEL_PREFIXES
from pyGBot.BasePlugin import BasePlugin
from twisted.internet import reactor
import logging
    def bot_part(self, channel):
        """ Called upon parting a channel. If parting the log channel, remove
        the channel handler from the logging object. """
        if self._active and channel == self.channel:
            self.removeChannelHandler()

    def bot_kicked(self, channel, kicker="", reason=""):
        """ Called upon being kicked from a channel. If kicked from the log
        channel, remove the channel handler from the logging object and attempt
        to rejoin. """
        if self._active and channel == self.channel:
            self.removeChannelHandler()
            self.bot.join(self.channel)

    def bot_disconnect(self):
        """ Called upon disconnecting from the server. Remove the channel
        handler from the logging object. """
        self.removeChannelHandler()

    # Log handler manipulation
    def addChannelHandler(self):
        """ Adds an IRC channel handler to the bot logging object. """

        if self._handler != None:
            self.removeChannelHandler()

        channelStream = ChannelStream(self.bot, self.channel)
        self._handler = logging.StreamHandler(channelStream)
        self._handler.setFormatter(self.format)
        self._handler.setLevel(self.loglevel)

# Path: pyGBot/log.py
# def addScreenHandler(logobj, format):
# def addLogFileHandler(logobj, filename, format):
# 
# Path: pyGBot/core.py
# CHANNEL_PREFIXES = '&#!+'
# 
# Path: pyGBot/BasePlugin.py
# class BasePlugin:
#     def __init__(self, bot, options):
#         self.bot = bot
# 
#     def activate(self, channel=None):
#         """
#         Called when the plugin is activated.
#         """
#         return True
# 
#     def deactivate(self, channel=None):
#         """
#         Called when the plugin is deactivated.
#         """
#         return True
# 
#     # Event handlers for other users
#     def user_join(self, channel, username):
#         pass
# 
#     def user_part(self, channel, username):
#         pass
# 
#     def user_kicked(self, channel, username, kicker, message=""):
#         pass
# 
#     def user_quit(self, username, reason=""):
#         pass
# 
#     def user_nickchange(self, username, newname):
#         pass
# 
#     # Event handlers for this bot
#     def bot_connect(self):
#         pass
# 
#     def bot_join(self, channel):
#         pass
# 
#     def bot_part(self, channel):
#         pass
# 
#     def bot_kicked(self, channel, kicker="", reason=""):
#         pass
# 
#     def bot_disconnect(self):
#         pass
# 
# 
#     # Event handlers for incoming messages
#     def msg_channel(self, channel, user, message):
#         pass
# 
#     def msg_action(self, channel, user, message):
#         pass
# 
#     def msg_private(self, user, message):
#         pass
# 
#     def msg_notice(self, user, message):
#         pass
# 
#     # Event handlers for channel information replies
#     def channel_names(self, channel, nameslist):
#         pass
# 
#     def channel_topic(self, channel, user, topic):
#         pass
# 
#     # Other system event handlers
#     def timer_tick(self):
#         pass


# Path: pyGBot/Plugins/system/Log2channel.py
from pyGBot import log
from pyGBot.core import CHANNEL_PREFIXES
from pyGBot.BasePlugin import BasePlugin
from twisted.internet import reactor
import logging

    def bot_part(self, channel):
        """ Called upon parting a channel. If parting the log channel, remove
        the channel handler from the logging object. """
        if self._active and channel == self.channel:
            self.removeChannelHandler()

    def bot_kicked(self, channel, kicker="", reason=""):
        """ Called upon being kicked from a channel. If kicked from the log
        channel, remove the channel handler from the logging object and attempt
        to rejoin. """
        if self._active and channel == self.channel:
            self.removeChannelHandler()
            self.bot.join(self.channel)

    def bot_disconnect(self):
        """ Called upon disconnecting from the server. Remove the channel
        handler from the logging object. """
        self.removeChannelHandler()

    # Log handler manipulation
    def addChannelHandler(self):
        """ Adds an IRC channel handler to the bot logging object. """

        if self._handler != None:
            self.removeChannelHandler()

        channelStream = ChannelStream(self.bot, self.channel)
        self._handler = logging.StreamHandler(channelStream)
        self._handler.setFormatter(self.format)
        self._handler.setLevel(self.loglevel)

        log.logger.addHandler(self._handler)