Пример #1
0
    def init(self, host="irc.freenode.net", port="6667", channel=channel):
        self.host = host
        self.port = int(port)

        # Add TCPClient and IRC to the system.
        TCPClient(channel=self.channel).register(self)
        IRC(channel=self.channel).register(self)
Пример #2
0
    def init(self, args):
        self.args = args

        self.logger = getLogger(__name__)
        if args.debug:
            self += Debugger(channel=self.channel,
                             IgnoreEvents=['_read', '_write', 'ping'])
            self += stdin
            #self += Debugger(logger=self.logger, channel=self.channel)

        self.buffers = defaultdict(bytes)

        self.nicks = {}
        self.users = {}
        self.channels = {}
        if ':' in args.bind:
            address, port = args.bind.split(':', 1)
            port = int(port)
        else:
            address, port = args.bind, 6667

        self.transport = TCPServer(bind=(address, port),
                                   channel=self.channel).register(self)

        self.protocol = IRC(
            channel=self.channel,
            getBuffer=self.buffers.__getitem__,
            updateBuffer=self.buffers.__setitem__).register(self)
Пример #3
0
    def init(self, args, logger=None):
        self.args = args
        self.logger = logger or getLogger(__name__)

        self.buffers = defaultdict(bytes)

        self.nicks = {}
        self.users = {}
        self.channels = {}

        Debugger(events=args.debug, logger=self.logger).register(self)

        if ":" in args.bind:
            address, port = args.bind.split(":")
            port = int(port)
        else:
            address, port = args.bind, 6667

        bind = (address, port)

        self.transport = TCPServer(
            bind,
            channel=self.channel
        ).register(self)

        self.protocol = IRC(
            channel=self.channel,
            getBuffer=self.buffers.__getitem__,
            updateBuffer=self.buffers.__setitem__
        ).register(self)
Пример #4
0
    def __init__(self, *args):
        ConfigurableComponent.__init__(self, "IRCBOT", *args)
        if self.config.get('password', None) is None:
            self.config.password = std_uuid()
            self.config.save()

        self.channel = 'ircbot'

        self.fireEvent(cli_register_event('test_irc_send', cli_test_irc_send), "isomer-web")
        self.log("Started")

        self.host = self.config.host
        self.port = self.config.port

        self.hostname = gethostname()

        self.nick = self.config.nick
        self.irc_channels = self.config.channels

        # Mapping of IRC Channel -> Set of Nicks
        self.channel_map = defaultdict(set)

        # Mapping of Nick -> Set of IRC Channels
        self.nick_map = defaultdict(set)

        # Add TCPClient and IRC to the system.
        self.transport = TCPClient(channel=self.channel).register(self)
        self.protocol = IRC(channel=self.channel).register(self)

        # Keep-Alive Timer
        Timer(60, Event.create("keepalive"), persist=True).register(self)
Пример #5
0
    def init(self, host, port="6667", channel=channel):
        self.host = host
        self.port = int(port)

        self.connected = False
        self.events = []

        self.transport = TCPClient(channel=self.channel).register(self)
        self.protocol = IRC(channel=self.channel).register(self)
Пример #6
0
    def __init__(self, host="irc.sudo-rmrf.net", port="6667", channel="#csb", nick="testbot", realname='IRC Bot'):
        super(IRCBot, self).__init__()
        self.host = host
        self.port = int(port)
        self.nick = nick
        self.channel = channel
        self.realname = realname

        # Add TCPClient and IRC to the system.
        TCPClient(channel=self.channel).register(self)
        IRC(channel=self.channel).register(self)
        self.fire(debugalert("Initialized!"))
Пример #7
0
    def init(self, host, port=6667, opts=None):
        self.host = host
        self.port = port
        self.opts = opts
        self.hostname = gethostname()

        self.nick = opts.nick
        self.ircchannel = opts.channel

        # Add TCPClient and IRC to the system.
        TCPClient(channel=self.channel).register(self)
        IRC(channel=self.channel).register(self)
Пример #8
0
    def setup(self):
        try:
            self.transport = self.Transport(
                self.bind, channel=self.channel).register(self)

            self.protocol = IRC(
                channel=self.channel,
                getBuffer=self.buffers.__getitem__,
                updateBuffer=self.buffers.__setitem__).register(self)
        except Exception as e:
            self.logger.error("Cannot start server: {0}".format(e))
            self.logger.info("Retrying in 5s ...")
            Timer(5, setup()).register(self)
Пример #9
0
    def init(self,
             nick="Botivator",
             command_char="!",
             owners=["Motivator", "MotivatorAFK"],
             password_file="password.py",
             host_file="host",
             host="irc.snoonet.org",
             port="6667",
             channel="##arctantest"):

        self.host = host
        self.port = int(port)

        self.nick = nick
        self.password = open(password_file).read().strip()

        self.command_char = command_char

        self.owners = owners
        self.owner_host = open(host_file).read().strip()

        self.linkresolver = LinkResolver()

        self.commands = {
            #'command_name': [CommandClass, CanAnyoneUseIt?]
            'commands': [Commands(), True],
            'help': [Commands(), True],
            'join': [Join(), True],
            'part': [Part(), True],
            'ban': [Ban(), False],
            'allow': [Allow(), False],
            'source': [Source(), True],
            '4chan': [WatchFourChan(self), False],
            'hn': [WatchHackerNews(self), False],
            'reddit': [WatchReddit(self), False],
            '8ch': [WatchEightChan(self), False],
            'pastebin': [WatchPasteBin(self), False],
            'quote': [Quote(), True],
        }

        # Add owner to whitelist
        self.commands['allow'][0].whitelist.append(self.owner_host)

        TCPClient(channel=self.channel).register(self)
        IRC(channel=self.channel).register(self)
Пример #10
0
    def init(self,
             host,
             port=None,
             secure=False,
             nick=None,
             ircchannels=None,
             channel=channel):
        self.host = host
        self.port = port or 6667
        self.hostname = gethostname()

        self.nick = nick
        self.ircchannel = ircchannels

        TCPClient(secure=secure, channel=self.channel).register(self)
        self.irc = IRC(channel=self.channel).register(self)

        self.last_called = 0
        self.max_rate = 1
        self.privmsg_queue = []
Пример #11
0
    def init(self, host, port=6667, opts=None):
        self.host = host
        self.port = port
        self.opts = opts
        self.hostname = gethostname()

        self.nick = opts.nick
        self.ircchannels = opts.channels

        # Mapping of IRC Channel -> Set of Nicks
        self.chanmap = defaultdict(set)

        # Mapping of Nick -> Set of IRC Channels
        self.nickmap = defaultdict(set)

        # Debugger
        Debugger(events=opts.verbose).register(self)

        # Add TCPClient and IRC to the system.
        self.transport = TCPClient(channel=self.channel).register(self)
        self.protocol = IRC(channel=self.channel).register(self)

        # Logger(s)
        for ircchannel in self.ircchannels:
            if not path.exists(path.join(opts.output, ircchannel)):
                makedirs(path.join(opts.output, ircchannel))

            Logger(path.join(opts.output, generate_logfile(ircchannel)),
                   "a",
                   channel="logger.{0:s}".format(ircchannel)).register(self)

        # Daemon?
        if self.opts.daemon:
            Daemon(opts.pidfile).register(self)

        # Keep-Alive Timer
        Timer(60, Event.create("keepalive"), persist=True).register(self)
Пример #12
0
    def init(self):
        IRC().register(self)

        self.data = []
        self.events = []