当前位置: 首页>>代码示例>>Python>>正文


Python client.IRCClient类代码示例

本文整理汇总了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()
开发者ID:Caber-nl,项目名称:wolfbot,代码行数:34,代码来源:wolfbot.py

示例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()
开发者ID:moebiuseye,项目名称:jeanneDHack-twittbot,代码行数:7,代码来源:irc_twit_bot.py

示例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
开发者ID:figgybit,项目名称:IRC-Tweet-BOT,代码行数:25,代码来源:irc_twit_bot.py

示例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()
开发者ID:ryepdx,项目名称:crowdmap_bot,代码行数:7,代码来源:crowdmap_bot.py

示例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()
开发者ID:lykoss,项目名称:lykos,代码行数:28,代码来源:wolfbot.py

示例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
开发者ID:BytesAndCoffee,项目名称:Marzipan,代码行数:8,代码来源:pan.py

示例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
开发者ID:Protospace,项目名称:protobot,代码行数:8,代码来源:oyoyo-bot.py

示例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
开发者ID:svineet,项目名称:Solari,代码行数:12,代码来源:client.py

示例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)
开发者ID:svineet,项目名称:Solari,代码行数:16,代码来源:activity.py

示例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()
开发者ID:nckomodo,项目名称:pesterchum,代码行数:8,代码来源:irc.py

示例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()
开发者ID:kernelpanic3,项目名称:lykos,代码行数:18,代码来源:wolfbot.py

示例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()
开发者ID:xbreaker,项目名称:breakbot,代码行数:57,代码来源:irc_bot.py

示例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)
开发者ID:SM-Networkx,项目名称:breakbot,代码行数:55,代码来源:irc_bot.py

示例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()
开发者ID:Asorailahd,项目名称:lykos,代码行数:20,代码来源:wolfbot.py

示例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)
开发者ID:rascul,项目名称:yamms,代码行数:20,代码来源:yamms.py


注:本文中的oyoyo.client.IRCClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。