Пример #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
 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
 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
 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
    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
 def error(self, nick, reason):
     print "error: %s " % reason
     try:
         time.sleep(2)
         helpers.join(cli, CHANNEL)
     except:
         main()
Пример #9
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))
Пример #10
0
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
    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
    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
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
 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)
 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)
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
def connect_cb(cli):
    global channels
    for c in channels:
        helpers.join(cli, c)
Пример #20
0
def connect_callback(cli):
    for CHANNEL in CHANNELS:
        helpers.join(cli, CHANNEL)
Пример #21
0
 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
    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
 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
def connect_cb(cli):
    helpers.join(cli, CHANNEL)
Пример #25
0
 def connect_cb(self, cli):
     for c in self.channels:
         helpers.join(cli, c)
Пример #26
0
 def connect_cb(self, unusued_cli):
     for channel in self.config.channels:
         helpers.join(self, channel)
Пример #27
0
 def connectcb(client):
     helpers.join(client, self.config['channel'])
Пример #28
0
 def join(self, channel):
     helpers.join(self.client, channel)
Пример #29
0
 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
 def join(self, channel):
     helpers.join(self.client, channel)
Пример #33
0
    def on_connect(self, cli):
        # Identify to nickserv
        helpers.identify(cli, self.passwd)

        # Join the channel
        helpers.join(cli, self.channel)
Пример #34
0
def connect_callback(cli):
    helpers.join(cli, config['channel'])
Пример #35
0
 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
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
 def join(self, sender, dest, arg):
     log.info('told to join %s by %s' % (arg, sender))
     helpers.join(self.client, arg.strip())
Пример #39
0
def connect_cb(cli):
    global channels
    for c in channels:
        helpers.join(cli, c)