def join(self, channel, password=None, nick=None): """ join conference. """ if channel.startswith("#"): return try: if not nick: nick = channel.split('/')[1] except IndexError: nick = self.nick channel = channel.split('/')[0] q = Queue.Queue() self.errorwait.register("409", q, 3) self.errorwait.register("401", q, 3) self.errorwait.register("400", q, 3) presence = Presence({'to': channel + '/' + nick}) if password: presence.x.password = password self.send(presence) errorobj = waitforqueue(q, 3000) if errorobj: err = errorobj[0].error logging.error('%s - error joining %s - %s' % (self.name, channel, err)) if err >= '400': if channel not in self.channels409: self.channels409.append(channel) return err self.timejoined[channel] = time.time() chan = ChannelBase(channel, self.botname) chan.data['nick'] = nick if password: chan.data['key'] = password if not chan.data.has_key('cc'): chan.data['cc'] = self.cfg['defaultcc'] or '!' if channel not in self.state['joinedchannels']: self.state['joinedchannels'].append(channel) self.state.save() if channel in self.channels409: self.channels409.remove(channel) return 1
def join(self, channel, password=None, nick=None): """ join conference. """ if channel.startswith("#"): return logging.warn("joining %s" % channel) try: if not nick: nick = channel.split('/')[1] except IndexError: nick = self.cfg.nick or "jsonbot" self.timejoined[channel] = time.time() chan = ChannelBase(channel, self.botname) chan.data['nick'] = nick if password: chan.data['key'] = password if chan.data['key'] and not password: password = chan.data['key'] if not chan.data.has_key('cc'): chan.data['cc'] = self.cfg['defaultcc'] or '!' if channel not in self.state['joinedchannels']: self.state['joinedchannels'].append(channel) self.state.save() if channel in self.channels409: self.channels409.remove(channel) chan.save() channel = channel.split('/')[0] q = Queue.Queue() presence = Presence({ 'to': channel + '/' + nick, "xmlns": 'http://jabber.org/protocol/muc' }) if password: presence.x = {} presence.x['password'] = password self.send(presence) return 1
def join(self, channel, password=None): """ join channel with optional password. """ if not channel: return if password: self._raw('JOIN %s %s' % (channel, password)) chan = ChannelBase(channel, self.botname) if chan: chan.setpass('IRC', password) else: self._raw('JOIN %s' % channel) if self.state: if channel not in self.state.data.joinedchannels: self.state.data.joinedchannels.append(channel) self.state.save()
def update_web(self, channel, txt, end="<br>"): from google.appengine.api.channel import channel as gchan chan = ChannelBase(channel, botname="gae-web") #logging.warn("%s - webchannels are %s" % (self.name, chan.data.webchannels)) remove = [] for c in chan.data.webchannels: try: if c: logging.debug("%s - sending to channel %s" % (self.name, chan)) gchan.send_message(c, txt + end) except gchan.InvalidChannelClientIdError: remove.append(c) if remove: for c in remove: chan.data.webchannels.remove(c) chan.save()
def handle_ievent(self, ievent): """ handle ircevent .. dispatch to 'handle_command' method. """ try: if ievent.cmnd == 'JOIN' or ievent.msg: if ievent.nick in self.nicks401: self.nicks401.remove(ievent.nick) logging.debug('%s - %s joined .. unignoring' % (self.name, ievent.nick)) if not ievent.chan and ievent.channel: ievent.chan = ChannelBase(ievent.channel, self.botname) method = getattr(self, 'handle_' + ievent.cmnd.lower()) if method: try: method(ievent) except: handle_exception() except AttributeError: pass try: self.wait.check(ievent) except: handle_exception()
def join(self, channel, password=None): """ join a channel .. use optional password. """ result = Irc.join(self, channel, password) if result != 1: return result chan = ChannelBase(channel, self.botname) got = False if password: chan.setkey('IRC',password) got = True if not chan.data.cc: chan.data.cc = self.cfg.defaultcc or '!' got = True if not chan.data.perms: chan.data.perms = [] got = True if not chan.data.mode: chan.data.mode = "" got = True if got: chan.save() self.getchannelmode(channel) return 1
def join(self, channel, password=None): """ join a channel .. use optional password. """ chan = ChannelBase(channel, self.cfg.name) if password: chan.data.key = password.strip() chan.save() result = Irc.join(self, channel, chan.data.key) if result != 1: return result got = False if not chan.data.cc: chan.data.cc = self.cfg.globalcc or '' got = True if not chan.data.perms: chan.data.perms = [] got = True if not chan.data.mode: chan.data.mode = "" got = True if got: chan.save() self.getchannelmode(channel) return 1