コード例 #1
0
 def joinChannel(self, channel):
     c = str(channel)
     try:
         helpers.join(self.cli, c)
         helpers.mode(self.cli, c, "", None)
     except socket.error:
         self.setConnectionBroken()
コード例 #2
0
ファイル: irc.py プロジェクト: Macman1234/pesterchum
 def welcome(self, server, nick, msg):
     self.parent.setConnected()
     mychumhandle = self.mainwindow.profile().handle
     mymood = self.mainwindow.profile().mood.value()
     if not self.mainwindow.config.lowBandwidth():
         helpers.join(self.client, "#pesterchum")
         helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))
コード例 #3
0
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
0
 def endofmotd(self, server, me, msg):
   """Used instead of a connect callback since it invokes too early."""
   self.client.send("MODE %s +B" % me)
   helpers.nick(self.client, "marzipan")
   helpers.join(self.client, "#playground")
   if self.client.logchan:
     helpers.join(self.client, self.client.logchan)
コード例 #5
0
ファイル: irc.py プロジェクト: Dariox/pesterchum
 def joinChannel(self, channel):
     c = unicode(channel)
     try:
         helpers.join(self.cli, c)
         helpers.mode(self.cli, c, "", None)
     except socket.error:
         self.setConnectionBroken()
コード例 #6
0
ファイル: pan.py プロジェクト: BytesAndCoffee/Marzipan
 def endofmotd(self, server, me, msg):
     """Used instead of a connect callback since it invokes too early."""
     self.client.send("MODE %s +B" % me)
     helpers.nick(self.client, "marzipan")
     helpers.join(self.client, "#playground")
     if self.client.logchan:
         helpers.join(self.client, self.client.logchan)
コード例 #7
0
ファイル: ccat.py プロジェクト: zigdon/CorpCat
    def welcome(self, nick, chan, msg):
        """Trigger on-login actions via the WELCOME event."""
        s = config['servers'][self.client.host]

        # If an auth is specified, use it.
        auth = s.get('auth')
        if auth:
            try:
                self._msg(auth['to'], auth['msg'])
            except KeyError:
                logging.error('Authentication info for %s missing "to" or "msg", skipping.' %
                    self.client.host)

        # If server-specific user modes are specified, set them.
        modes = s.get('modes')
        if modes:
            self.client.send('MODE', s['nick'], modes)

        time.sleep(10)
        for corp in self.corps.itervalues():
            if corp['server'] == self.client.host:
                helpers.join(self.client, corp['channel'])

        logging.info("Completed initial connection actions for %s." % self.client.host)
        self.WELCOMED = True
コード例 #8
0
 def error(self, nick, reason):
     print "error: %s " % reason
     try:
         time.sleep(2)
         helpers.join(cli, CHANNEL)
     except:
         main()
コード例 #9
0
ファイル: irc.py プロジェクト: rlee287/serious-business
 def welcome(self, server, nick, msg):
     self.parent.setConnected()
     mychumhandle = self.mainwindow.profile().handle
     mymood = self.mainwindow.profile().mood.value()
     if not self.mainwindow.config.lowBandwidth():
         helpers.join(self.client, "#pesterchum")
         helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))
コード例 #10
0
ファイル: irc.py プロジェクト: i3detroit/i3Twitterbot
def connect_callback(cli):
    if IDENT:
        irclogger.debug('Identifying with %s.'%IDENT)
        helpers.identify(cli,IDENT)
    else:
        irclogger.debug('NOT identifying')
    helpers.user(cli,NICK,NAME)
    for CHAN in CHANS:
        helpers.join(cli, CHAN)
コード例 #11
0
 def welcome(self, server, nick, msg):
     self.parent.setConnected()
     mychumhandle = self.mainwindow.profile().handle
     mymood = self.mainwindow.profile().mood.value()
     if not self.mainwindow.config.lowBandwidth():
         from time import sleep
         sleep(0.5) # To prevent TLS from dying </3
         helpers.join(self.client, "#pesterchum")
         helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))
コード例 #12
0
ファイル: ccat.py プロジェクト: zigdon/CorpCat
    def _cmd_JOIN(self, nick, mask, chan, arg):
        """ADMIN: join <channel> - Make the bot join the specified channel."""
        usage = lambda: self._msg(chan, "Usage: join <channel>")

        if not arg:
            return usage()

        self._msg(chan, "Joining channel %s." % arg)
        helpers.join(self.client, arg)
コード例 #13
0
ファイル: irc.py プロジェクト: nckomodo/pesterchum
    def welcome(self, server, nick, msg):
        self.parent.setConnected()
        helpers.join(self.client, "#pesterchum")
        mychumhandle = self.mainwindow.profile().handle
        mymood = self.mainwindow.profile().mood.value()
        helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))

        chums = self.mainwindow.chumList.chums
        self.getMood(*chums)
コード例 #14
0
ファイル: irc.py プロジェクト: i3detroit/i3Twitterbot
def join(self,nick,chan,msg):
    if authed(self,nick,chan):
        if msg not in CHANS:
            CHANS.append(msg)
            config.set('IRC','channels',','.join(CHANS))
            helpers.join(cli, msg)
            helpers.msg(self.client,chan,'%s: OK, I joined %s'%(nick,msg))
        elif msg == chan:
            helpers.msg(self.client,chan,'%s: Um...this *is* %s...'%(nick,msg))
        else:
            helpers.msg(self.client,chan,'%s: Um...I am *already* in %s...'%(nick,msg))
コード例 #15
0
 def welcome(self, server, nick, msg):
     self.parent.setConnected()
     mychumhandle = self.mainwindow.profile().handle
     mymood = self.mainwindow.profile().mood.value()
     if not self.mainwindow.config.lowBandwidth():
         helpers.join(self.client, "#pesterchum")
         helpers.msg(self.client, "#pesterchum", "MOOD >%d" % (mymood))
         # We override the +T that's set by default, for now, to reenable
         # CTCP communication.
         # Because of the potential for spam, Low Bandwidth mode still
         # disables this...this will likely change in the future.
         helpers.mode(self.client, mychumhandle, "-T")
コード例 #16
0
ファイル: ircterm.py プロジェクト: i3detroit/i3ircterm
 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)
コード例 #17
0
 def quit(self, nick, reason):
     try:
         try:
             main()
         except:
             print "ircinit or main failure"
             try:
                 main()
             except:
                 print '"You get nothing done" -- Axl\' Rose'
                 pass
     except:
         print "something went wrong."
     helpers.join(cli, CHANNEL)
コード例 #18
0
def main():
    global conn
    global respond_to
    i = 0
    old_id = 0
    start = time.time()
    while True:
        time.sleep(0.5)
        if i < 200:
            i += 1
        if i == 100:
            print "joining"
            helpers.join(cli, CHANNEL)
        if i == 200:
            print "joining"
            helpers.join(cli, CHANNEL)
            i += 1
        if i > 200:
            mentions = []
            if time.time() - start > 20:
                start = time.time()
                print "getting goodies"
                try:
                    mentions = api.mentions()
                    mentions = mentions[:1]  ## Get only the last mention
                except:
                    mentions = []
                    pass
            mentions.reverse()
            for mention in mentions:
                if mention.id > old_id:
                    text = HTMLParser().unescape(mention.text)
                    helpers.msg(cli, CHANNEL, "@%s nous dis : %s" % (mention.author.screen_name, text))
                    respond_to = mention.author.screen_name
                    old_id = mention.id + 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 KeyboardInterrupt:
            print "Interrupted"
            exit()
        except:
            pass
        conn.next()  ## python 2
コード例 #19
0
ファイル: client.py プロジェクト: svineet/Solari
def connect_cb(cli):
    global channels
    for c in channels:
        helpers.join(cli, c)
コード例 #20
0
ファイル: bot.py プロジェクト: LeftyBC/lefty-pybot
def connect_callback(cli):
    for CHANNEL in CHANNELS:
        helpers.join(cli, CHANNEL)
コード例 #21
0
ファイル: IRC.py プロジェクト: marqui678/finalchance.Panopta
 def join_cb(client):
     self.log.info("called join callback")
     client.got_nick_event.wait()                
     helpers.join(client, channel)
     helpers.msg(client, channel, text)
コード例 #22
0
ファイル: IRC.py プロジェクト: marqui678/finalchance.Panopta
    def send(self, text, **kwargs):

        server, channel = self.contact_info.split("/")
        try: server, port = server.split(":")
        except: port = "6667"
        
        server = server.strip().lower()
        channel = channel.strip()
        port = int(port.strip())
        
        # for referencing in active_connectoins
        key = "%s:%d" % (server, port)
        
        
        # do we already have an existing connection?
        active = self.active_connections.get(key, None)
        if active:
            self.log.info("found existing connection to %s" % key)
            conn, client = active
            client.started = time.time()
            client.command_handler.channel_cache[channel] = self.channel
            client.connected_event.wait()
            helpers.join(client, channel)
            helpers.msg(client, channel, text)
        
        # or do we need a new connection?
        else:            
            def connect_cb(client):
                self.log.info("called connect callback")
                client.connected_event.send()
                eventlet.spawn_n(join_cb, client)
                
            def join_cb(client):
                self.log.info("called join callback")
                client.got_nick_event.wait()                
                helpers.join(client, channel)
                helpers.msg(client, channel, text)
            
            self.log.info("we need a new irc connection to %s", key)
            client = IRCClient(
                IRCHandler, host=server,
                port=port, nick="PanoptaOutage",
                connect_cb=connect_cb, blocking=True
            )
            client.connected_event = eventlet.event.Event()
            client.got_nick_event = eventlet.event.Event()
            client.command_handler.channel_cache[channel] = self.channel
            client.command_handler.log = self.log
            client.command_handler.server = server
            client.started = time.time()
            client.blocking = False
            
            self.log.info("connecting to %s", key)
            conn = client.connect()
            
            self.active_connections[key] = (conn, client)
        
            # this will disconnect after 60 seconds
            def persist_in_background():
                client.started = time.time()
                self.log.info("idling connection to %s for %d seconds" % (key, IRC.timeout))
                
                while client.started + IRC.timeout > time.time() and conn.next():
                    time.sleep(0.5)

                self.log.info("disconnecting from %s" % key)
                del self.active_connections[key]
                
                quit_messages = [
                    "herpderp",
                    "I want to die peacefully in my sleep, like my grandfather.. Not screaming like the passengers in his car.",
                    "Do not argue with an idiot. He will drag you down to his level and beat you with experience.",
                    "If I agreed with you we'd both be wrong.",
                    "The early bird might get the worm, but the second mouse gets the cheese.",
                    "I thought I wanted a career, turns out I just wanted paychecks.",
                    "I didn't say it was your fault, I said I was blaming you.",
                ]
                helpers.quit(client, random.choice(quit_messages))
                    
            eventlet.spawn_n(persist_in_background)
        
        return "irc message to %s" % self.contact_info
コード例 #23
0
 def kick(self, kickernick, chan, mynick, reason):
     print "kick: %s " % reason
     if reason not in ["perma", "permanent", "perm", "flood", "flooding"]:
         time.sleep(2)
         helpers.join(cli, CHANNEL)
コード例 #24
0
ファイル: ircd.py プロジェクト: corywalker/robotics_logger
def connect_cb(cli):
    helpers.join(cli, CHANNEL)
コード例 #25
0
ファイル: activity.py プロジェクト: svineet/Solari
 def connect_cb(self, cli):
     for c in self.channels:
         helpers.join(cli, c)
コード例 #26
0
ファイル: tablecat.py プロジェクト: Protospace/protobot
 def connect_cb(self, unusued_cli):
     for channel in self.config.channels:
         helpers.join(self, channel)
コード例 #27
0
ファイル: ircear.py プロジェクト: maitred/maitred
 def connectcb(client):
     helpers.join(client, self.config['channel'])
コード例 #28
0
ファイル: irc.py プロジェクト: jelmer/fs-uae-debian
 def join(self, channel):
     helpers.join(self.client, channel)
コード例 #29
0
ファイル: app.py プロジェクト: gagan0123/oyoyo
 def connect_cb(c):
     if identify: 
         helpers.ns(c, "IDENTIFY", identify)
     for room in rooms:
         helpers.join(c, "#"+room)
コード例 #30
0
def connect_callback(cli):
	# Join the channel
	# TODO multi servers?
	# TODO loop api, join channels by key
	helpers.join(cli, "#channel")
コード例 #31
0
 def endofmotd(self, server, target, text):
     for channel in config.get('irc', 'channels').split(','):
         helpers.join(self.client, channel)
コード例 #32
0
ファイル: irc.py プロジェクト: EdwardBetts/fs-uae-launcher
 def join(self, channel):
     helpers.join(self.client, channel)
コード例 #33
0
ファイル: crowdmap_bot.py プロジェクト: ryepdx/crowdmap_bot
    def on_connect(self, cli):
        # Identify to nickserv
        helpers.identify(cli, self.passwd)

        # Join the channel
        helpers.join(cli, self.channel)
コード例 #34
0
ファイル: botanus.py プロジェクト: template1/botanus
def connect_callback(cli):
    helpers.join(cli, config['channel'])
コード例 #35
0
ファイル: builtincommands.py プロジェクト: rispari/flipper
 def handle(self, message):
     if re.match("(#|!)\w+", message.params):
         helpers.join(message.client, message.params) #@UndefinedVariable IGNORE:E1101
     else:
         self.replytoinvalidparams(message)
コード例 #36
0
def connect_cb(cli):
    helpers.join(cli, CHANNEL)
コード例 #37
0
ファイル: yamms.py プロジェクト: rascul/yamms
def connect_callback(bot):
	nickpass = config.get('yamms', 'nickpass')
	helpers.msg(bot, "NickServ", "IDENTIFY %s" % (nickpass,))
	channel = config.get('yamms', 'channel')
	helpers.join(bot, channel)
コード例 #38
0
ファイル: app.py プロジェクト: gagan0123/oyoyo
 def join(self, sender, dest, arg):
     log.info('told to join %s by %s' % (arg, sender))
     helpers.join(self.client, arg.strip())
コード例 #39
0
ファイル: client.py プロジェクト: svineet/Solari
def connect_cb(cli):
    global channels
    for c in channels:
        helpers.join(cli, c)