Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@sugarlabs.org>2011-10-26 18:37:02 (GMT)
committer Aleksey Lim <alsroot@sugarlabs.org>2011-10-26 18:37:02 (GMT)
commit73ec930524c1840568528fff31d5d26064fed538 (patch)
tree651918b4c8e0a055dd7489da79dcfd80f5ca46e6
parent74024d9d8ff4442f51d7178418e9b041af0809eb (diff)
Add #olpc-aprendizaje channel; add new channels from config
-rw-r--r--config.py3
-rw-r--r--lingva_bot.py2
-rw-r--r--plugin.py32
3 files changed, 34 insertions, 3 deletions
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):
+ """[<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):
"""[<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]