def joinChannel(self, channel): c = str(channel) try: helpers.join(self.cli, c) helpers.mode(self.cli, c, "", None) except socket.error: self.setConnectionBroken()
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))
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
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)
def joinChannel(self, channel): c = unicode(channel) try: helpers.join(self.cli, c) helpers.mode(self.cli, c, "", None) except socket.error: self.setConnectionBroken()
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()
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)
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))
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)
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)
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))
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")
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
def connect_cb(cli): global channels for c in channels: helpers.join(cli, c)
def connect_callback(cli): for CHANNEL in CHANNELS: helpers.join(cli, CHANNEL)
def join_cb(client): self.log.info("called join callback") client.got_nick_event.wait() helpers.join(client, channel) helpers.msg(client, channel, text)
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)
def connect_cb(cli): helpers.join(cli, CHANNEL)
def connect_cb(self, cli): for c in self.channels: helpers.join(cli, c)
def connect_cb(self, unusued_cli): for channel in self.config.channels: helpers.join(self, channel)
def connectcb(client): helpers.join(client, self.config['channel'])
def join(self, channel): helpers.join(self.client, channel)
def connect_cb(c): if identify: helpers.ns(c, "IDENTIFY", identify) for room in rooms: helpers.join(c, "#"+room)
def connect_callback(cli): # Join the channel # TODO multi servers? # TODO loop api, join channels by key helpers.join(cli, "#channel")
def endofmotd(self, server, target, text): for channel in config.get('irc', 'channels').split(','): helpers.join(self.client, channel)
def on_connect(self, cli): # Identify to nickserv helpers.identify(cli, self.passwd) # Join the channel helpers.join(cli, self.channel)
def connect_callback(cli): helpers.join(cli, config['channel'])
def handle(self, message): if re.match("(#|!)\w+", message.params): helpers.join(message.client, message.params) #@UndefinedVariable IGNORE:E1101 else: self.replytoinvalidparams(message)
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)
def join(self, sender, dest, arg): log.info('told to join %s by %s' % (arg, sender)) helpers.join(self.client, arg.strip())