From 73ec930524c1840568528fff31d5d26064fed538 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Wed, 26 Oct 2011 18:37:02 +0000 Subject: Add #olpc-aprendizaje channel; add new channels from config --- diff --git a/config.py b/config.py index db4ecc4..c7d2367 100644 --- a/config.py +++ b/config.py @@ -45,6 +45,9 @@ conf.registerGlobalValue(Lingvo, 'contact', conf.registerGlobalValue(Lingvo, 'documentation_url', registry.String('http://wiki.sugarlabs.org/go/Service/meeting/Usage', 'Url to the site with documentations')) +conf.registerGlobalValue(Lingvo, 'channels', + conf.SpaceSeparatedSetOfChannels([], + 'List of channels that are permitted to be translated')) conf.registerChannelValue(Lingvo, 'pinned', registry.Boolean(False, 'Should empty translation channels be auto closed')) diff --git a/lingva_bot.py b/lingva_bot.py index cc8c904..e3036b8 100644 --- a/lingva_bot.py +++ b/lingva_bot.py @@ -7,6 +7,8 @@ CHANNELS = [ ('en', '#sugar', 'Common Sugar discussions'), ('en', '#sugar-newbies', 'New Sugar developer help'), ('en', '#sugar-meeting', 'Handling Sugar meetings'), + ('', '', 'Learning channels'), + ('es', '#olpc-aprendizaje', 'Latin America education team channel'), ('', '', 'Sugar distributions'), ('en', '#dextrose', 'Sugar distribution for XO laptops'), ('en', '#fedora-olpc', 'The home of the Fedora interest group for OLPC'), diff --git a/plugin.py b/plugin.py index 2496a3e..d36ea91 100644 --- a/plugin.py +++ b/plugin.py @@ -70,7 +70,9 @@ class Lingvo(callbacks.Plugin): if self._groups_value is None: self._groups_value = {} - for lang, name, __ in config.CHANNELS: + for lang, name, __ in config.CHANNELS + \ + [('en', str(i), None) for i in \ + self.registryValue('channels')]: if not lang: continue @@ -83,6 +85,7 @@ class Lingvo(callbacks.Plugin): if group_channel == group.channel and lang: group[i] = lang + self.log.info('[lingvo] Add lingva channel %s', name) self._groups_value[name] = group return self._groups_value @@ -126,8 +129,10 @@ class Lingvo(callbacks.Plugin): group_channel, __ = _normalize_channel(channel) if group_channel not in self._groups: irc.error('Channel "%s" cannot be translated, ' \ - 'request it using %s contact' % \ - (group_channel, self.registryValue('contact'))) + 'request it using %s contact, ' \ + 'permitted channels are %s' % \ + (group_channel, self.registryValue('contact'), + ', '.join(self._groups.keys()))) return group = self._groups[group_channel] @@ -261,6 +266,26 @@ class Lingvo(callbacks.Plugin): unpin = wrap(cmd_unpin, ['channel']) + def cmd_lingvanicks(self, irc, msg, args, channel): + """[] + + List all nicks that are on translation channels. + """ + if channel: + if not channel.startswith('#'): + channel = '#' + channel + channel, __ = _normalize_channel(channel) + + for group in sorted(self._groups.values(), + cmp=lambda x, y: cmp(x.channel, y.channel)): + if channel and channel != group.channel or not group: + continue + for lingva_channel in group.keys(): + nicks = irc.state.channels[lingva_channel].users + irc.reply('%s: %s' % (lingva_channel, ', '.join(nicks))) + + lingvanicks = wrap(cmd_lingvanicks, [optional('channel')]) + def cmd_nicks(self, irc, msg, args, channel): """[] @@ -297,6 +322,7 @@ class Lingvo(callbacks.Plugin): if time_last is None: self._auto_parts[channel] = time_current elif time_current - time_last >= self.registryValue('timeout'): + self.log.info('[lingvo] Timeout part from %s', channel) irc.queueMsg(ircmsgs.part(channel, 'Lingvo part')) elif channel in self._auto_parts: del self._auto_parts[channel] -- cgit v0.9.1