aboutsummaryrefslogtreecommitdiffstats
path: root/plugin.py
diff options
context:
space:
mode:
authorkongr45gpen <kongr45gpen@helit.org>2013-07-24 17:58:38 +0300
committerkongr45gpen <kongr45gpen@helit.org>2013-07-24 17:58:38 +0300
commita42348f4cac5ad97fccc9aaaf08243ff426ec546 (patch)
treeac4a10cd86a8cf876c0c7148a1337f1a4adf857c /plugin.py
parent9f6be16bd5ec2e15c8bab3d3b567d9ca90d88975 (diff)
downloadsupybot_github-a42348f4cac5ad97fccc9aaaf08243ff426ec546.tar.gz
supybot_github-a42348f4cac5ad97fccc9aaaf08243ff426ec546.tar.bz2
supybot_github-a42348f4cac5ad97fccc9aaaf08243ff426ec546.zip
Add support for plural forms
Diffstat (limited to 'plugin.py')
-rw-r--r--plugin.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/plugin.py b/plugin.py
index 9a665b5..264c5d2 100644
--- a/plugin.py
+++ b/plugin.py
@@ -40,6 +40,10 @@ import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
+def plural(number, s, p):
+ if number != 1:
+ return p
+ return s
class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
@@ -61,8 +65,13 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# print json.dumps(data, sort_keys=True, indent=4, separators=(',', ': '))
for irc in world.ircs:
msgs = []
- #TODO: Plural
- msgs.append( ircmsgs.privmsg("#main", "%s pushed %i %s, check them out" % (data['pusher']['name'], len(data['commits']), "commits")) )
+
+ commitno = len(data['commits'])
+ msgs.append( ircmsgs.privmsg("#main", "%s pushed %i %s, check them out" %
+ (data['pusher']['name'],
+ commitno,
+ plural(commitno, "commit", "commits"))) )
+
msgs.append( ircmsgs.privmsg("#main", "%s" % (data['compare'])) )
for msg in msgs:
irc.queueMsg(msg)

© 2014-2024 Faster IT GmbH | imprint | privacy policy