示例#1
0
    def __init__(self, server_list, nickname, realname, reconnection_interval=60):
        """Constructor for SingleServerIRCBot objects.

        Arguments:

            server_list -- A list of tuples (server, port) that
                           defines which servers the bot should try to
                           connect to.

            nickname -- The bot's nickname.

            realname -- The bot's realname.

            reconnection_interval -- How long the bot should wait
                                     before trying to reconnect.

            dcc_connections -- A list of initiated/accepted DCC
            connections.
        """

        SimpleIRCClient.__init__(self)
        self.channels = IRCDict()
        self.server_list = server_list
        if not reconnection_interval or reconnection_interval < 0:
            reconnection_interval = 2**31
        self.reconnection_interval = reconnection_interval

        self._nickname = nickname
        self._realname = realname
        for i in ["disconnect", "join", "kick", "mode",
                  "namreply", "nick", "part", "quit"]:
            self.connection.add_global_handler(i,
                                               getattr(self, "_on_" + i),
                                               -10)
示例#2
0
    def __init__(self):
        SimpleIRCClient.__init__(self)

        self.channel = "#pfclol"

        self.nick_re = re.compile("^([^!]+)!")
        self.message_queue = []
        self.event_queue = []

        # We might be connected, but we're not ready yet.
        self.online = False
        self.hasMotd = False

        # But when we see some magic words, we will be.
        self.connection.add_global_handler("motdstart", self.connect_parse, -10)
        self.connection.add_global_handler("endofmotd", self.connect_parse, -10)
        self.connection.add_global_handler("luserconns", self.connect_parse, -10)
        
        # Unless we're not, anymore.
        self.connection.add_global_handler("disconnect", self.connect_parse, -10)

        # And once we're online, we want to pay attention.
        self.connection.add_global_handler("privmsg", self.parse_msg, -5)
        self.connection.add_global_handler("pubmsg", self.parse_msg, -5)
        self.connection.add_global_handler("join", self.parse_msg, -5)
        self.connection.add_global_handler("part", self.parse_msg, -5)  
        self.connection.add_global_handler("kick", self.parse_msg, -5)  
        self.connection.add_global_handler("quit", self.parse_msg, -5)  
示例#3
0
    def __init__(self, server_list, nickname, realname, reconnection_interval=60):
        """Constructor for SingleServerIRCBot objects.

        Arguments:

            server_list -- A list of tuples (server, port) that
                           defines which servers the bot should try to
                           connect to.

            nickname -- The bot's nickname.

            realname -- The bot's realname.

            reconnection_interval -- How long the bot should wait
                                     before trying to reconnect.

            dcc_connections -- A list of initiated/accepted DCC
            connections.
        """

        SimpleIRCClient.__init__(self)
        self.channels = IRCDict()
        self.server_list = server_list
        if not reconnection_interval or reconnection_interval < 0:
            reconnection_interval = 2**31
        self.reconnection_interval = reconnection_interval

        self._nickname = nickname
        self._realname = realname
        for i in ["disconnect", "join", "kick", "mode",
                  "namreply", "nick", "part", "quit"]:
            self.connection.add_global_handler(i,
                                               getattr(self, "_on_" + i),
                                               -10)
示例#4
0
 def __init__(self, config, listner):
     SimpleIRCClient.__init__(self)
     self.server = config['irc']['server']
     self.port = 6667
     self.nickname = self._generate_nick()
     self.channel = config['irc']['channel']
     self.listner = listner
示例#5
0
 def __init__(self, config, listner):
     SimpleIRCClient.__init__(self)
     self.server = config['irc']['server']
     self.port = 6667
     self.nickname = self._generate_nick()
     self.channel = config['irc']['channel']
     self.listner = listner
示例#6
0
 def __init__(self, channel, input, output):
     SimpleIRCClient.__init__(self)
     self.channel=channel
     self.channels = {}
     self.joined_channels = {}
     self.lol = False
     self.pubblicata = False
示例#7
0
文件: bot.py 项目: SMFOSS/DoulaBot
 def __init__(self, verbose=False, channels=[channel]):
     SimpleIRCClient.__init__(self)
     self.count = count()
     self.verbose = verbose
     self.logged = False
     self._irc_log = []
     host, port = self.redis_server.split(':')
     self.redis = redis.Redis(host, int(port))
     self.channels = channels
     self.channel = channels[0]
示例#8
0
 def __init__(self, verbose=False, channels=[channel]):
     SimpleIRCClient.__init__(self)
     self.count = count()
     self.verbose = verbose
     self.logged = False
     self._irc_log = []
     host, port = self.redis_server.split(':')
     self.redis = redis.Redis(host, int(port))
     self.channels = channels
     self.channel = channels[0]
示例#9
0
文件: lpbot.py 项目: bb-btc/bitHopper
	def __init__(self):
		SimpleIRCClient.__init__(self)
		self.nick = 'lp' + str(random.randint(1,9999999999))
		self.connection.add_global_handler('disconnect', self._on_disconnect, -10)
		self.chan_list=[]
		self.newblock_re = re.compile('\*\*\* New Block \{(?P<server>.+)\} - (?P<hash>.*)')
		self.hashes = ['']
		self.hashinfo = {}
		self.server=''
		self.current_block=''
		# TODO: Use twisted
		thread.start_new_thread(self.run,())
		thread.start_new_thread(self.ircobj.process_forever,())
示例#10
0
文件: lpbot.py 项目: Gnaget/bitHopper
 def __init__(self, bitHopper):
     SimpleIRCClient.__init__(self)
     self.bitHopper = bitHopper
     self.nick = 'lp' + str(random.randint(1,9999999999))
     self.chan_list=[]
     self.newblock_re = re.compile('\*\*\* New Block \{(?P<server>.+)\} - (?P<hash>.*)')
     self.hashes = ['']
     self.hashinfo = {'':''}
     self.server=''
     self.current_block=''
     # TODO: Use twisted
     thread.start_new_thread(self.run, ())
     thread.start_new_thread(self.ircobj.process_forever,())
示例#11
0
    def __init__(self, config):
        '''Sets up two things from the configuration file: the
        connection information that is used by the SimpleIRCClient
        parent class and the information needed by the core class that
        adds interactive functionality to the bot.
        '''
        bot = config['Connection']

        SimpleIRCClient.__init__(self)
        self.connect(bot['server'], bot['port'], bot['nick'], bot['pw'],
                     bot['name'])

        self.ops = bot['ops']
        self.chans = bot['chans']
        self.about = bot['about']

        self.core = core.BotCore(self, self.ops, self.chans, self.about)
示例#12
0
    def __init__(self, config):
        '''Sets up two things from the configuration file: the
        connection information that is used by the SimpleIRCClient
        parent class and the information needed by the core class that
        adds interactive functionality to the bot.
        '''
        bot = config['Connection']

        SimpleIRCClient.__init__(self)
        self.connect(bot['server'], bot['port'], bot['nick'],
                     bot['pw'], bot['name'])

        self.ops   = bot['ops']
        self.chans = bot['chans']
        self.about = bot['about']

        self.core   = core.BotCore(self, self.ops, self.chans, self.about)
示例#13
0
    def __init__(self, irc_data, extended=None, reconnection_interval=60):
        """Constructor for SingleServerIRCBot objects.

		Arguments:

			server_list -- A list of tuples (server, port) that
						   defines which servers the bot should try to
						   connect to.

			nickname -- The bot's nickname.

			realname -- The bot's realname.

			reconnection_interval -- How long the bot should wait
									 before trying to reconnect.

			dcc_connections -- A list of initiated/accepted DCC
			connections.
		"""

        SimpleIRCClient.__init__(self)
        self.channels = IRCDict()
        self.irc_data = irc_data
        self.extended = extended

        reconnection_interval = irc_data['reconnection_interval']
        if not reconnection_interval or reconnection_interval < 0:
            reconnection_interval = 2**31
        self.reconnection_interval = reconnection_interval
        self.label = irc_data['label']
        self.folders = irc_data['folders']
        self.triggers = irc_data['triggers']
        self.otherbots = irc_data['otherbots']

        for i in [
                "disconnect", "join", "kick", "mode", "namreply", "nick",
                "nicknameinuse", "part", "quit", "welcome", "320",
                "endofwhois", "nosuchnick"
        ]:
            self.connection.add_global_handler(i, getattr(self, "_on_" + i),
                                               -10)
        self.commands = {}
        self.replies = replies
        self.nicks = {}
示例#14
0
 def start(self):
     """Start the bot."""
     success = self._connect()
     if success:
         SimpleIRCClient.start(self)
示例#15
0
    def __init__(self, server_list, connection_kwargs, reconnection_interval=60):
        """Constructor for SingleServerIRCBot objects.

        Arguments:

            server_list -- A list of dicts containing connection arguments.

            connection_kwargs -- Dict of connection arguments.

            reconnection_interval -- How long the bot should wait
                                     before trying to reconnect.

        How a connection is made:

            When a connection is made the arguments from connection_kwargs are
            used but then overridden by the arguments for the currect server.

            The only requirement is that all servers need to contain server and
            port key and connection_kwargs need to contain nickname key

            Other than that you can send in anything that
            SimpleIRCClient.connect() accept. This means that you don't have to
            change this class if you change the arguments to
            SimpleIRCClient.connect()

        Example:

            server_list = [
                {
                    'server': 'www.example1.com',
                    'port': '6669',
                },
                {
                    'server': 'www.example2.com',
                    'port': '6669',
                },
                {
                    'server': 'www.example3.com',
                    'port': '6669',
                    'ssl': False,
                },
            ]

            connection_kwargs = {
                'nickname': 'bot',
                'ssl': True,
            }

            This config means that ssl will be used for example1 and 2 but not 3

        """

        SimpleIRCClient.__init__(self)
        self.channels = IRCDict()
        self.server_list = server_list
        self.connection_kwargs = connection_kwargs

        for server in self.server_list:
            if not "server" in server or not "port" in server:
                raise Exception("All servers need to contain a port and server")

        if not "nickname" in self.connection_kwargs:
            raise Exception("connection_kwargs need to contain a nickname")

        if not reconnection_interval or reconnection_interval < 0:
            reconnection_interval = 2 ** 31
        self.reconnection_interval = reconnection_interval

        for i in ["disconnect", "join", "kick", "mode", "namreply", "nick", "part", "quit"]:
            self.connection.add_global_handler(i, getattr(self, "_on_" + i), -10)
示例#16
0
 def __init__(self, channel, input, output):
     SimpleIRCClient.__init__(self)
     self.channel = channel
     self.channels = {}
示例#17
0
 def start(self):
     """Start the bot."""
     success = self._connect()
     if success:
         SimpleIRCClient.start(self)
示例#18
0
 def start(self):
     """Start the bot."""
     self._connect()
     SimpleIRCClient.start(self)
示例#19
0
 def start(self):
     """Start the bot."""
     self._connect()
     SimpleIRCClient.start(self)
示例#20
0
 def start(self):
     '''Starts the IRC bot, which gets it to connect to the server
     that has been specified.
     '''
     SimpleIRCClient.start(self)
示例#21
0
 def start(self):
     '''Starts the IRC bot, which gets it to connect to the server
     that has been specified.
     '''
     SimpleIRCClient.start(self)