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" channel = channel.split('/')[0] q = Queue.Queue() presence = Presence({'to': channel + '/' + nick, "xmlns": 'http://jabber.org/protocol/muc' }) if password: presence.x.password = password self.send(presence) 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) chan.save() 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 update_web(self, channel, txt): from google.appengine.api.channel import channel as gchan chan = ChannelBase(channel, botname="gae-web") logging.warn("%s - webchannels are %s" % (self.cfg.name, chan.data.webchannels)) remove = [] for c in chan.data.webchannels: try: if c: logging.warn("%s - sending %s to channel %s" % (self.cfg.name, txt, c)) gchan.send_message(c, txt) except gchan.InvalidChannelClientIdError: remove.append(c) if remove: for c in remove: chan.data.webchannels.remove(c) ; logging.warn("%s - closing channel %s" % (self.cfg.name, c)) chan.save()
def stop(self, botname, type, name, channel): """ stop watching a feed. """ item = self.byname(name) if not item: return False try: logging.warn("trying to remove %s from %s feed list" % (name, channel)) chan = ChannelBase(channel, botname) chan.data.feeds.remove(name) chan.save() except ValueError: logging.warn("can't remove %s from %s feed list" % (name, channel)) try: item.data.watchchannels.remove([botname, type, channel]) item.save() logging.debug("stopped %s feed in %s channel" % (name, channel)) except ValueError: return False return True
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 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
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() # logging.warn("%s - using key %s for channel %s" % (self.cfg.name, chan.data.key, channel)) 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.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