Пример #1
0
    def __init__(self, args, datastore):
        self.args = args
        self.datastore = datastore
        self.responder = Responder(args, datastore, self)

        if args.use_irc:
            self.ircbot = IRCBot(args)
Пример #2
0
def background():
    '''
    load and maintain cache

    communicate with other kybyz servers
    '''
    delay = int(os.getenv('KB_DELAY') or 600)  # seconds
    CACHED['ircbot'] = IRCBot(nickname=CACHED.get('username', None))
    while True:
        logging.info('kybyz active %s seconds', CACHED['uptime'], **TO_PAGE)
        time.sleep(delay)  # releases the GIL for `serve`
        CACHED['uptime'] += delay
        logging.debug('CACHED: %s, threads: %s',
                      CACHED, threading.enumerate())
Пример #3
0
def run():
    args = parse_args()
    verbosity_levels = {
        'error': logging.WARNING,
        'bot': logging.INFO,
        'debug': logging.DEBUG,
        'dump': logging.NOTSET,
    }
    logging.basicConfig(
        level=verbosity_levels[args.verbosity],
        format='%(levelname)-8s %(message)s',
    )

    bot = IRCBot(args.channel, args.nick)
    reactor.connectTCP(args.server, args.port, bot)
    reactor.run()
Пример #4
0
def main():
    server = settings.SERVER
    port = settings.PORT
    channel = settings.CHANNEL
    nickname = settings.NICKNAME

    lichessmate = lichess.LichessBot()

    # LenientDecodingBuffer attempts UTF-8 but falls back to latin-1 to avoid UnicodeDecoreError in all cases.
    irc.client.ServerConnection.buffer_class = buffer.LenientDecodingLineBuffer
    ircbot = IRCBot(channel, nickname, server, port, lichessmate, settings)

    try:
        # Start a new thread for running Lichess, send the ircbot instance to it.
        _thread.start_new_thread(run_lichess, (lichessmate, ircbot))
    except _thread.error:
        print_error('Error: Unable to start thread.')

    ircbot.start()
Пример #5
0
# coding: latin-1

from ircbot import IRCBot
from httpsrv import http_server
import time
import settings
import datetime
import sys

if settings.nick == "CHANGEME":
    print "---> Please customize settings.py and try again. <---"
    sys.exit(0)

bot = IRCBot(settings.server_address, settings.server_port, settings.nick,
             settings.username, settings.realname)

#web_server = http_server.HTTPServer(8000)

botnik_picture_data = None


def handle_request(request):
    if request.request_path == "/botnik.png":
        global botnik_picture_data

        if not botnik_picture_data:
            try:
                file = open("botnik.png")
                botnik_picture_data = file.read()
                file.close()
            except:
Пример #6
0
parser = argparse.ArgumentParser(description='Python IRC bot.')
parser.add_argument('--verbose', action='store_true',
                    help='Become more verbose.')
parser.add_argument('config', type=str,
                    help='A py file with the bot\'s config.')
arguments = parser.parse_args()

# Load the config from the given file
if not os.path.exists(arguments.config):
    raise ValueError('Config file {}'
            'does not exist.'.format(arguments.config,))
config = imp.load_source('config', arguments.config)

# Set verbose mode if needed
VERBOSE = config.VERBOSE or arguments.verbose

# Create the bot
ircbot = IRCBot()
ircbot.setup(config)

# Load the actions from the specified modules
for path in config.MODULES:
    if not os.path.exists(path):
        raise ValueError('Module %s does not exist.' % (path, ))
    name = os.path.basename(path)[:-3]
    module = imp.load_source(name, path)

# Start the bot
asyncore.loop()
Пример #7
0
for x in sys.argv:
    if x[0] == '-':
        if x[1] == 'd':
            is_daemon = True
        else:
            print """[+] Minicar Operating Program by jyp
            -d: Daemonize this app.
            """
if __name__ == '__main__':
    if is_daemon:
        pid = os.fork()  # Demonize itself
    else:
        pid = 0
    if pid == 0:
        # Initialize
        b = IRCBot(config['irc']['channels'])

        def __init():
            b.connect(config['irc']['host'][0], config['irc']['host'][1],
                      config['irc']['nickname'])
            return b

        def __notifier(m):
            b.connection.privmsg(config['irc']['channels'][0], m)

        # Threads
        threads = []

        # Add services
        threads.append(
            threading.Thread(target=wifi.start, args=(__init, __notifier)))
Пример #8
0
def main():
    bot = IRCBot()
    bot.run()
Пример #9
0
import yaml
from ircbot import IRCBot
from channelmodule import ChannelModule
from permissionmodule import PermissionModule
from autoopmodule import AutoOPModule
from titlemodule import TitleModule
from calcmodule import CalcModule
from codeforcesmodule import CodeForcesModule
from adminmodule import AdminModule
from dynamicmoduleloadermodule import DynamicModuleLoaderModule

if __name__ == '__main__':
    settings = yaml.load(open('settings.yaml'))

    bot = IRCBot(settings['nick'], settings['user'], settings['realname'])
    for network, server in settings['servers'].items():
        bot.connect(network, **server)

    bot.install_module(ChannelModule, channels=settings['channels'])
    bot.install_module(PermissionModule)
    bot.install_module(AutoOPModule)
    bot.install_module(TitleModule)
    bot.install_module(CalcModule)
    bot.install_module(CodeForcesModule)
    bot.install_module(AdminModule)
    bot.install_module(DynamicModuleLoaderModule)

    bot.run()