# Path: pyGBot/log.py
# def addScreenHandler(logobj, format):
# def addLogFileHandler(logobj, filename, format):
# 
# 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


import hashlib
from pyGBot import log
from pyGBot.BasePlugin import BasePlugin
from contrib.configobj import ConfigObj

    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):
        if message.lower().startswith('auth'):
            if self.authtype == "nickserv":
                self.bot.privout("nickserv", "acc %s *" % user)
                log.logger.info('Auth: Attempting to auth %s' % user)
            if self.authtype == "pygbot":
                if len(message.rsplit(' ',2)) == 3:
                    cmd, uname, password = message.rsplit(' ',2)
                    if self.get_passhash(uname) == hashlib.sha1((password + u'pygb0t').encode('utf-8', 'replace')).hexdigest():
                        authlevel = self.get_authlevel(uname)
                        if authlevel != None:
                            self.set_userlevel(user, self.get_authlevel(uname))
                            self.bot.noteout(user, 'Successfully authed.')
                            log.logger.info('Auth: Authorized user %s at level %d.' % (user, authlevel))
                        else:
                            self.bot.noteout(user, 'Invalid user level.')

# Path: pyGBot/log.py
# def addScreenHandler(logobj, format):
# def addLogFileHandler(logobj, filename, format):
# 
# 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/Auth.py
import hashlib
from pyGBot import log
from pyGBot.BasePlugin import BasePlugin
from contrib.configobj import ConfigObj


    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):
        if message.lower().startswith('auth'):
            if self.authtype == "nickserv":
                self.bot.privout("nickserv", "acc %s *" % user)
                log.logger.info('Auth: Attempting to auth %s' % user)
            if self.authtype == "pygbot":
                if len(message.rsplit(' ',2)) == 3:
                    cmd, uname, password = message.rsplit(' ',2)
                    if self.get_passhash(uname) == hashlib.sha1((password + u'pygb0t').encode('utf-8', 'replace')).hexdigest():
                        authlevel = self.get_authlevel(uname)
                        if authlevel != None:
                            self.set_userlevel(user, self.get_authlevel(uname))
                            self.bot.noteout(user, 'Successfully authed.')
                            log.logger.info('Auth: Authorized user %s at level %d.' % (user, authlevel))
                        else:
                            self.bot.noteout(user, 'Invalid user level.')

                            log.logger.info('Auth: Invalid user level for user %s' % user)