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


Python IRCClient.connect方法代码示例

本文整理汇总了Python中oyoyo.client.IRCClient.connect方法的典型用法代码示例。如果您正苦于以下问题:Python IRCClient.connect方法的具体用法?Python IRCClient.connect怎么用?Python IRCClient.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oyoyo.client.IRCClient的用法示例。


在下文中一共展示了IRCClient.connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connect

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
    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,代码行数:9,代码来源:crowdmap_bot.py

示例2: main

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:27,代码来源:irc_twit_bot.py

示例3: ircinit

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:9,代码来源:irc_twit_bot.py

示例4: main

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:10,代码来源:oyoyo-bot.py

示例5: IRCInterface

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:59,代码来源:irc_bot.py

示例6: IRCInterface

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:57,代码来源:irc_bot.py

示例7: get_connected_client

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:14,代码来源:client.py

示例8: PesterIRC

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
class PesterIRC(QtCore.QThread):
    def __init__(self, config, window):
        QtCore.QThread.__init__(self)
        self.mainwindow = window
        self.config = config
        self.registeredIRC = False
        self.stopIRC = None
        self.NickServ = services.NickServ()
        self.ChanServ = services.ChanServ()
    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='pcc31', blocking=True, timeout=120)
        self.cli.command_handler.parent = self
        self.cli.command_handler.mainwindow = self.mainwindow
        self.cli.connect()
        self.conn = self.cli.conn()
    def run(self):
        try:
            self.IRCConnect()
        except socket.error, se:
            self.stopIRC = se
            return
        while 1:
            res = True
            try:
                logging.debug("updateIRC()")
                res = self.updateIRC()
            except socket.timeout, se:
                logging.debug("timeout in thread %s" % (self))
                self.cli.close()
                self.stopIRC = se
                return
            except socket.error, se:
                if self.registeredIRC:
                    self.stopIRC = None
                else:
                    self.stopIRC = se
                logging.debug("socket error, exiting thread")
                return
开发者ID:bludgeoningPolitician,项目名称:pesterchum,代码行数:42,代码来源:irc.py

示例9: _start

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
    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,代码行数:18,代码来源:activity.py

示例10: IrcEar

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
class IrcEar(Ear):
    def write(self, text):
        helpers.msg(self.client, self.config['channel'], text)
    def connect(self):
        class Handler(DefaultCommandHandler):
            def privmsg(self_handler, nick, chan, msg):
                user = nick.decode().split('!')[0]
                text = msg.decode()
                self.handle_message(user, text)
        def connectcb(client):
            helpers.join(client, self.config['channel'])
        self.client = IRCClient(Handler, host=self.config['host'],
                port=self.config['port'], nick=self.config['nick'],
                connect_cb=connectcb)
        self.connection = self.client.connect()
    def sync(self):
        next(self.connection)
开发者ID:maitred,项目名称:maitred,代码行数:19,代码来源:ircear.py

示例11: IRCMain

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
class IRCMain(object):
    def __init__(self,server='irc.freenode.net',port=6667,channel='#i3detroit',
                 nick='i3ircterm',realname='IRC Terminal at i3Detroit',
                 user='i3ircterm',password=None,printer=None):
        logger = logging.getLogger('IRCTerm.IRCMain')
        # setting up connection parameters
        self.server = server
        self.port = port
        self.channel = channel
        self.nick = nick
        self.realname = realname
        self.user = user
        self.password = password
        self.printer = printer
        self.cli = None
        
        if self.printer is None:
            logger.warn('No printer in use, using console instead')
        
    def connect(self):
        logger = logging.getLogger('IRCTerm.IRCMain.connect')
        if self.cli is None:
            logger.debug('Connecting to %s:%s as %s'%\
                         (self.server,self.port,self.nick))
            self.cli = IRCClient(IRCHandler, host=self.server, port=self.port,
                                   nick=self.nick, connect_cb=self.connect_callback)
            self.cli.command_handler.printer = self.printer
            self.conn = self.cli.connect()
        else:
            logger.warn('Already connected...')
        return self.conn

    def connect_callback(self,cli):
        logger = logging.getLogger('IRCTerm.IRCMain.connect_callback')
        logger.debug('user %s realname %s nick %s'%\
                (self.user,self.realname,self.nick))
        helpers.user(self.cli,self.user,self.realname)
        
        if self.password is not None:
            logger.debug('Identifying %s with %s'%(self.nick,self.password))
            helpers.identify(self.cli,self.password)
        else:
            logger.debug('No identify required')
        logger.info('Joining %s'%self.channel)
        helpers.join(self.cli,self.channel)
开发者ID:i3detroit,项目名称:i3ircterm,代码行数:47,代码来源:ircterm.py

示例12: main

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
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,代码行数:22,代码来源:yamms.py

示例13: _connect_and_run

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
    def _connect_and_run(self):
        cli = IRCClient(IRCThreadCallbackHandler,
                        host=self.irc_host,
                        port=self.irc_port,
                        nick=self.irc_nick)

        self.ping_last_reply = time.time()
        self.ping_sent_at = False
        self.pong_queue.clear()

        conn = cli.connect()
        while True:
            next(conn)
            while len(self.cmd_queue) > 0:
                cmd = self.cmd_queue.popleft()
                target = cmd[1]
                msg = cmd[2]
                logging.info('Handling event (%s) -> (%s, %s)' % (cmd, target, msg))
                helpers.msg(cli, target, msg)

            self._check_connection(cli)

            time.sleep(0.2)
开发者ID:dal00,项目名称:sms900,代码行数:25,代码来源:ircthread.py

示例14: open

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
import sys
from oyoyo.client import IRCClient
from constants import SETTINGS_FILE
from handler import KevinBotCommandHandler

# Main program
if __name__ == '__main__':
    try:
        f = open(SETTINGS_FILE, 'r')
        settings = json.load(f)
    except (IOError, ValueError):
        print >> sys.stderr,\
            ('File %s is missing or unreadable, or has an invalid format' %
             SETTINGS_FILE)
        exit(1)
    finally:
        f.close()
    # HACK: IRCClient.__init__ is expecting a class name that it can use to
    # construct a new handler object. This lambda expression allows us to
    # pass parameters to the handler's constructor, avoiding the need for
    # global variables.
    cli = IRCClient(lambda client: KevinBotCommandHandler(client, settings),
                    host = settings['host'],
                    port = settings['port'],
                    nick = settings['nick'],
                    blocking = True)
    conn = cli.connect()
    while True:
        conn.next()
    print 'Exiting.'
开发者ID:t3nsor,项目名称:kevinbot,代码行数:32,代码来源:main.py

示例15: __init__

# 需要导入模块: from oyoyo.client import IRCClient [as 别名]
# 或者: from oyoyo.client.IRCClient import connect [as 别名]
class IRC:
    def __init__(self):
        self.running = False
        self.stopping = False
        self.nick_number = 0
        self.channels = {}
        self.my_nick = ""
        self.client = None
        # FIXME: should not be hardcoded here
        self.default_channel = LOBBY_CHANNEL
        self.active_channel_name = self.default_channel
        self.connection = None

    def message(self, message, color=None):
        self.channel(self.active_channel_name).message(message, color)

    def warning(self, message):
        self.message(message, IRCColor.WARNING)

    def info(self, message):
        self.message(message, IRCColor.INFO)

    @staticmethod
    def is_channel(name):
        return len(name) > 0 and name[0] in "&#+!"

    def channel(self, name):
        # FIXME: name should be checked case independently
        if not name:
            name = self.default_channel

        from .channel import Channel
        try:
            return self.channels[name]
        except KeyError:
            print("new channel", repr(name))
            self.channels[name] = Channel(self, name)
            print("channels are now", repr(self.channels))
            # self.set_active_channel(name)
            IRCBroadcaster.broadcast("channel_list", {"added": name})
            return self.channels[name]

    def active_channel(self):
        return self.channel(self.active_channel_name)

    def set_active_channel_name(self, name):
        self.active_channel_name = name
        IRCBroadcaster.broadcast("active_channel", {"channel": name})

    def connect(self):
        self.start()

    def start(self):
        self.stopping = False
        if self.running:
            print("IRC.start - already running")
            return
        threading.Thread(target=self.irc_thread,
                         name="IRCThread").start()
        self.running = True

    def stop(self):
        if not self.running:
            return
        self.stopping = True
        helpers.quit(self.client, "Exited")
        # self.client.quit()

    def irc_thread(self):
        try:
            self.irc_main()
        except Exception as e:
            def func():
                self.warning(repr(e))

            call_after(func)
            import traceback
            traceback.print_exc()
        self.running = False

    @staticmethod
    def nick(spec):
        nick = spec.split("!")[0]
        nick = nick.strip("@+")
        return nick

    def me(self, spec):
        nick = spec.split("!")[0]
        return nick == self.my_nick

    @staticmethod
    def get_irc_server_host():
        return LauncherSettings.get_irc_server()

    def irc_main(self):
        def func():
            self.message("connecting to {0}...".format(
                    self.get_irc_server_host()))

        call_after(func)
#.........这里部分代码省略.........
开发者ID:EdwardBetts,项目名称:fs-uae-launcher,代码行数:103,代码来源:irc.py


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