本文整理汇总了Python中oyoyo.client.IRCClient类的典型用法代码示例。如果您正苦于以下问题:Python IRCClient类的具体用法?Python IRCClient怎么用?Python IRCClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IRCClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
if not botconfig.DEBUG_MODE:
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler("errors.log")
fh.setLevel(logging.WARNING)
logger.addHandler(fh)
if botconfig.VERBOSE_MODE:
hdlr = logging.StreamHandler(sys.stdout)
hdlr.setLevel(logging.DEBUG)
logger.addHandler(hdlr)
formatter = UTCFormatter('[%(asctime)s] %(message)s', '%d/%b/%Y %H:%M:%S')
for handler in logger.handlers:
handler.setFormatter(formatter)
else:
logging.basicConfig(level=logging.DEBUG)
formatter = UTCFormatter('[%(asctime)s] %(message)s', '%H:%M:%S')
for handler in logging.getLogger().handlers:
handler.setFormatter(formatter)
cli = IRCClient(
{"privmsg":modules.common.on_privmsg,
"notice":lambda a, b, c, d: modules.common.on_privmsg(a, b, c, d, True),
"":modules.common.__unhandled__},
host=botconfig.HOST,
port=botconfig.PORT,
authname=botconfig.USERNAME,
password=botconfig.PASS,
nickname=botconfig.NICK,
sasl_auth=botconfig.SASL_AUTHENTICATION,
use_ssl=botconfig.USE_SSL,
connect_cb=modules.common.connect_callback
)
cli.mainLoop()
示例2: ircinit
def ircinit():
global conn
global cli
## Setting IRC cli.
## logging.basicConfig(level=logging.DEBUG)
cli = IRCClient(MyHandler, host=HOST, port=PORT, nick=NICK) # ,connect_cb=connect_cb)
conn = cli.connect()
示例3: main
def main():
logging.basicConfig(level=logging.DEBUG)
cli = IRCClient(MyHandler, host=HOST, port=PORT, nick=NICK)#,connect_cb=connect_cb)
conn = cli.connect()
i = 0
while True:
if i < 1000000:
i+=1
if i == 1000:
print 'joining'
helpers.join(cli, CHANNEL)
if i == 1000000:
print 'joining'
helpers.join(cli, CHANNEL)
helpers.msg(cli, CHANNEL, 'connected')
i+=1
try:
item = status_queue.get(False)
print str(item.author.screen_name)
if str(item.author.screen_name) != NICK:
helpers.msg(cli, CHANNEL, str(item.author.screen_name)+' -- '+str(item.text))
api.update_status(str(item.author.screen_name)+' -- '+str(item.text))
except:
pass
conn.next() ## python 2
示例4: connect
def connect(self):
cli = IRCClient(MsgHandler, host=self.host, port=self.port,
nick=self.nick, connect_cb=self.on_connect)
conn = cli.connect()
while self.running:
conn.next()
示例5: main
def main():
evt = Event("init", {})
evt.dispatch()
src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
cli = IRCClient(
{"privmsg": lambda *s: None,
"notice": lambda *s: None,
"": handler.unhandled},
host=botconfig.HOST,
port=botconfig.PORT,
authname=botconfig.USERNAME,
password=botconfig.PASS,
nickname=botconfig.NICK,
ident=botconfig.IDENT,
real_name=botconfig.REALNAME,
sasl_auth=botconfig.SASL_AUTHENTICATION,
server_pass=botconfig.SERVER_PASS,
use_ssl=botconfig.USE_SSL,
cert_verify=var.SSL_VERIFY,
cert_fp=var.SSL_CERTFP,
client_certfile=var.SSL_CERTFILE,
client_keyfile=var.SSL_KEYFILE,
cipher_list=var.SSL_CIPHERS,
tokenbucket=TokenBucket(var.IRC_TB_BURST, var.IRC_TB_DELAY, init=var.IRC_TB_INIT),
connect_cb=handler.connect_callback,
stream_handler=src.stream,
)
cli.mainLoop()
示例6: __init__
def __init__(self, logchannel=None, **kwargs):
"""Uses PanHandler automatically."""
IRCClient.__init__(self, PanHandler, **kwargs)
print
"Successfully created", self
self.channels = IRCDict()
self.db = MongoClient(document_class=SON).mzpn
self.logchan = logchannel
示例7: main
def main():
logging.basicConfig(level=logging.DEBUG)
cli = IRCClient(MyHandler, host=HOST, port=PORT, nick=NICK, connect_cb=connect_cb)
conn = cli.connect()
while True:
conn.next() ## python 2
示例8: get_connected_client
def get_connected_client(activity, host, port,
nick, channels1, handler=BasicHandler):
global channels
channels = channels1.split(",")
cli = IRCClient(
handler,
host=host,
port=port,
nick=nick,
connect_cb=connect_cb)
conn = cli.connect()
return conn
示例9: _start
def _start(self, widget, nick, server, channels, port):
self.channels = [c.strip() for c in channels.split(",")]
client = IRCClient(
BasicHandler,
host=server,
port=port,
nick=nick,
connect_cb=self.connect_cb)
client.get_handler().set_activity(self)
self._connection = client.connect()
GObject.idle_add(self._next_con)
self.irc_widget = IRCWidget()
self.set_canvas(self.irc_widget)
示例10: IRCConnect
def IRCConnect(self):
server = self.config.server()
port = self.config.port()
self.cli = IRCClient(PesterHandler, host=server, port=int(port), nick=self.mainwindow.profile().handle, real_name='pcc30', blocking=True, timeout=15)
self.cli.command_handler.parent = self
self.cli.command_handler.mainwindow = self.mainwindow
self.cli.connect()
self.conn = self.cli.conn()
示例11: main
def main():
cli = IRCClient(
{"privmsg": handler.on_privmsg,
"notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
"": handler.unhandled},
host=botconfig.HOST,
port=botconfig.PORT,
authname=botconfig.USERNAME,
password=botconfig.PASS,
nickname=botconfig.NICK,
ident=botconfig.IDENT,
real_name=botconfig.REALNAME,
sasl_auth=botconfig.SASL_AUTHENTICATION,
use_ssl=botconfig.USE_SSL,
connect_cb=handler.connect_callback,
stream_handler=src.stream,
)
cli.mainLoop()
示例12: IRCInterface
class IRCInterface(threading.Thread):
def __init__(self, server, port, nick, channels, msg_handler, stopped_handler):
threading.Thread.__init__(self)
self.must_run = True
self.connected = False
self.msg_handler = msg_handler
self.stopped_handler = stopped_handler
self.nick = nick
self.host = server
self.port = port
self.channels = channels
self.send_queue = Queue()
self.channels_joined = {}
for c in self.channels:
self.channels_joined[c] = False
self.cli = IRCClient(Handler, host=self.host, port=self.port, nick=self.nick, connect_cb=self.connect_callback)
self.cli.command_handler.set_irc_interface(self)
@catch_them_all
def connect_callback(self, cli):
self.server_connected = True
def pending_channels(self):
result = True
for k, v in self.channels_joined.items():
if not v:
result = False
break
return result
def joined(self, channel):
self.channels_joined[channel] = True
info("Joined channel %s" % channel)
def parted(self, channel):
self.channels_joined[channel] = False
info("Left channel %s" % channel)
if self.must_run:
self.join_channels()
def connect(self):
info("Connecting to server")
self.server_connected = False
self.conn = self.cli.connect()
while not self.server_connected:
if not self.must_run:
raise Exception("Must stop")
self.conn.next()
info("Connected to server")
def next(self):
try:
self.conn.next()
except Exception, e:
time.sleep(0.05)
error("Couldn't process connection: %s" % e)
self.connect()
示例13: IRCInterface
class IRCInterface(threading.Thread):
def __init__(self, server, port, nick, owner, channels, msg_handler, stopped_handler):
threading.Thread.__init__(self)
self.must_run = True
self.connected = False
self.server_spamcheck = False
self.spamcheck_enabled = True
self.msg_handler = msg_handler
self.stopped_handler = stopped_handler
self.nick = nick
self.host = server
self.port = port
self.channels = channels
self.owner = 'Owner:'+owner+''
self.send_queue = Queue()
self.channels_joined = {}
for c in self.channels:
self.channels_joined[c] = False
self.cli = IRCClient(Handler, host=self.host, port=self.port, nick=self.nick, connect_cb=self.connect_callback, real_name=self.owner)
self.cli.command_handler.set_irc_interface(self)
@catch_them_all
def connect_callback(self, cli):
self.server_connected = True
def pending_channels(self):
result = True
for k,v in self.channels_joined.items():
if not v:
result = False
break
return result
def joined(self, channel):
self.channels_joined[channel] = True
info(2, "Joined channel %s" %channel)
def parted(self, channel):
self.channels_joined[channel] = False
info(2, "Left channel %s" %channel)
if self.must_run:
self.join_channels()
def connect(self):
info(2, "Connecting to server")
self.server_connected = False
self.conn = self.cli.connect()
while not self.server_connected:
if not self.must_run:
raise Exception("Must stop")
try:
self.conn.next()
except Exception, e:
error("Problems while connecting to IRC server: %s" %e)
self.stop()
self.disconnected()
info(2, "Connected to server")
info(3, "Setting Botmode on IRC queue")
self.send_queue.put("MODE %s +B" %self.nick)
示例14: main
def main():
src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
cli = IRCClient(
{"privmsg": handler.on_privmsg,
"notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
"": handler.unhandled},
host=botconfig.HOST,
port=botconfig.PORT,
authname=botconfig.USERNAME,
password=botconfig.PASS,
nickname=botconfig.NICK,
ident=botconfig.IDENT,
real_name=botconfig.REALNAME,
sasl_auth=botconfig.SASL_AUTHENTICATION,
server_pass=botconfig.SERVER_PASS,
use_ssl=botconfig.USE_SSL,
connect_cb=handler.connect_callback,
stream_handler=src.stream,
)
cli.mainLoop()
示例15: main
def main():
loglevel = config.get('yamms', 'loglevel')
if (loglevel == "error"):
logging.basicConfig(level=logging.ERROR)
elif (loglevel == "info"):
logging.basicConfig(level=logging.INFO)
elif (loglevel == "debug"):
logging.basicConfig(level=logging.DEBUG)
host = config.get('yamms', 'server')
port = config.getint('yamms', 'port')
nick = config.get('yamms', 'nick')
bot = IRCClient(BotHandler, host=host, port=port, nick=nick, connect_cb=connect_callback)
conn = bot.connect()
while True:
conn.next()
# stop sucking up the cpus!
time.sleep(.1)