本文整理汇总了Python中irclib.SimpleIRCClient.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleIRCClient.__init__方法的具体用法?Python SimpleIRCClient.__init__怎么用?Python SimpleIRCClient.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类irclib.SimpleIRCClient
的用法示例。
在下文中一共展示了SimpleIRCClient.__init__方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
def __init__(self, channel, input, output):
SimpleIRCClient.__init__(self)
self.channel=channel
self.channels = {}
self.joined_channels = {}
self.lol = False
self.pubblicata = False
示例4: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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]
示例6: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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,())
示例7: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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,())
示例8: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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)
示例9: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
def __init__(self, channel, input, output):
SimpleIRCClient.__init__(self)
self.channel = channel
self.channels = {}
示例10: __init__
# 需要导入模块: from irclib import SimpleIRCClient [as 别名]
# 或者: from irclib.SimpleIRCClient import __init__ [as 别名]
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)