diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2012-01-16 23:24:40 -0500 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2012-01-16 23:24:40 -0500 |
| commit | 2b679d318b65d090fb75668d26d6e85ea250b771 (patch) | |
| tree | 5053a7f40c105f1883e31bc93994cf40a52bcbc5 /misc/git-post-commit.py | |
| parent | 18ac8babb1d40b291468058d9125a1598434f543 (diff) | |
| parent | 73b2c72961544b42229dd334fc75a20d52acff9b (diff) | |
| download | alias-2b679d318b65d090fb75668d26d6e85ea250b771.tar.gz | |
Merge branch 'master' of alias.fr.nf:alias
Diffstat (limited to 'misc/git-post-commit.py')
| -rwxr-xr-x | misc/git-post-commit.py | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/misc/git-post-commit.py b/misc/git-post-commit.py new file mode 100755 index 0000000..07eeb60 --- /dev/null +++ b/misc/git-post-commit.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +""" +Simple script to send messages to an IRC channel +in Fire and Forget mode (non persistent connection) + +Usage: git-post-commit <server[:port]> <nickname> <channel> + +Read lines one by one on the standard input and print them in +in the channel +""" + +import irclib +import sys + +class IRCFire(irclib.SimpleIRCClient): + def __init__(self, target): + irclib.SimpleIRCClient.__init__(self) + self.target = target + + def on_welcome(self, connection, event): + connection.join(self.target) + + def on_join(self, connection, event): + for line in sys.stdin: + self.connection.privmsg(self.target, line) + self.connection.quit("Commit sent") + + def on_disconnect(self, connection, event): + sys.exit(0) + +def main(): + if len(sys.argv) != 4: + print "Usage: " + sys.argv[0] + " <server[:port]> <nickname> <channel>" + sys.exit(1) + + s = sys.argv[1].split(":", 1) + server = s[0] + if len(s) == 2: + try: + port = int(s[1]) + except ValueError: + print "Error: Erroneous port." + sys.exit(1) + else: + port = 6667 + nickname = sys.argv[2] + channel = sys.argv[3] + + c = IRCFire(channel) + try: + c.connect(server, port, nickname) + except irclib.ServerConnectionError, x: + print x + sys.exit(1) + c.start() + +if __name__ == "__main__": + main() + + |
