Exemplo n.º 1
0
def quit(server, message = '', delete=True):
    connections[server].send('QUIT :' + message +'\r\n')
    connections[server].running=False
    log.info('Killing conenction: ' + server)
    log.info('Reason: ' + message)
    if delete:
        del connections[server]
Exemplo n.º 2
0
 def connect(self, nick, username, hostname, servername, realname, timeout=0.2):
     self.socket_lock.acquire()
     log.info('Connecting to ' + self.name)
     self.sock = socket.socket ( socket.AF_INET, socket.SOCK_STREAM )
     self.sock.connect(( self.server, self.port))
     self.nick = nick
     nick_line = 'NICK '+ self.nick + '\r\n'
     self.sock.send ( nick_line.encode('utf-8') )
     self.username = username
     self.hostname = hostname
     self.servername = servername
     self.realname = realname
     user_line = 'USER {0} {1} {2} :{3}\r\n'.format(username, hostname, servername, realname)
     self.sock.send(user_line.encode('utf-8'))
     self.sock.settimeout(timeout)
     self.socket_lock.release()
Exemplo n.º 3
0
def loadPlugin(plugin_name):        
    try:
        # Loading system plugins
        filepath, pathname, description = imp.find_module(plugin_name, eyercbot.plugins.__path__)
        moduleSource = pathname +'/plugin.py'
        moduleSource = moduleSource.replace ( '\\', '/' )
        handle = open ( moduleSource )
        module = imp.load_module ( plugin_name, handle, ( moduleSource ), ( '.py', 'r', imp.PY_SOURCE ) )
        # This batch of code will be good for loading plugins in the user directory (which will happen after main ones)
        #moduleSource = 'plugins/'+plugin_name+'/plugin.py'
        #name = moduleSource.replace ( '.py', '' ).replace ( '\\', '/' ).split ( '/' ) [ 1 ]
        #handle = open ( moduleSource )
        #module = imp.load_module ( name, handle, ( moduleSource ), ( '.py', 'r', imp.PY_SOURCE ) )
        
        # Populate the main database
        plugins[plugin_name.lower()] = module
        if hasattr(module, 'alias_map'):
            for alias, function in module.alias_map.items():
                # Sometimes function may be a dict with function and threaded
                # We must check for this
                if type(function) is not dict:
                    eyercbot.messenger.add(alias, function)
                else:
                    eyercbot.messenger.add(alias, function['function'], threaded=function['threaded'])
                
        if hasattr(module, 'event_map'):
            for alias, function in module.event_map.items():
                # Sometimes function may be a dict with function and threaded
                if type(function) is not dict:
                    eyercbot.messenger.add(alias, function)
                else:
                    eyercbot.messenger.add(alias, function['function'], threaded=function['threaded'])
        
        reboot = None
        # Will now check and update configs as needed
        if module.HAS_CONFIG:        
            reboot = managePluginConfig(plugin_name, module.config, module.CONFIG_VERSION)
            if reboot: eyercbot.saveConfig()
        log.info("Plugin",plugin_name,"loaded.")
        return reboot
    except:
        log.warning("I couldn't load",plugin_name + '. I placed a report in errlog.txt for you.')
        import traceback
        traceback.print_exc(file=open("errlog.txt","a"))
        return None
Exemplo n.º 4
0
def auto_steam(*args):
    log.info("Automatic steam update")
    for userO, game in steamers.items():
        update = False
        database = get_steam(userO.steamID64)
        if 'gameextrainfo' in database and steamers[userO] == None:
            update = True
            steamers[userO] = database['gameextrainfo']
        elif 'gameextrainfo' not in database:
            steamers[userO] = None
        elif 'gameextrainfo' in database:
            if steamers[userO] != database['gameextrainfo']:
                update = True
                steamers[userO] = database['gameextrainfo']
        if update:
            for server in eyercbot.config['plugin_config']['steam']['servers']:
                for channel in eyercbot.config['plugin_config']['steam']['servers'][server]:
                    eyercbot.send('msg', server, channel, userO.nick + " is now playing " + database['gameextrainfo'])
Exemplo n.º 5
0
        for channel in eyercbot.config['plugin_config']['stats']['servers'][
                server]:
            update(channel + '.html', server, channel, auto=True)


if 'stats' in eyercbot.config['plugin_config']:
    minute, hour, day, month, day_of_week = eyercbot.config['plugin_config'][
        'stats']['frequency'].split(' ')
    eyercbot.scheduler.add_cron_job(midnight,
                                    second='0',
                                    month=month,
                                    day=day,
                                    hour=hour,
                                    minute=minute,
                                    day_of_week=day_of_week)
    log.info('Added auto stats to scheduler')


def print_url(server, user, target, message):
    url = eyercbot.config['plugin_config']['stats']['url']
    eyercbot.send(
        'sendMsg', server, user, target,
        'Channel statistics URL: ' + url + target.lstrip('#') + '.html')


def generate(server, user, target, message):
    for server in eyercbot.config['plugin_config']['stats']['servers']:
        for channel in eyercbot.config['plugin_config']['stats']['servers'][
                server]:
            update(channel.lstrip('#') + '.html', server, channel)
Exemplo n.º 6
0
def saveConfig():
    stream = open(config['nick'] + '.yaml', 'w')
    yaml.dump(config, stream)
    stream.close()
    log.info("Configuration saved")
Exemplo n.º 7
0
 def irc_ERR_NOMOTD(self, server, prefix, params):
     '''Server is unable to open its MOTD file'''
     server = prefix
     target = params[0]
     explaination = params[1]
     log.info("Server is unable to offer a MOTD")