summaryrefslogtreecommitdiffstats
path: root/Reaktor/IRC/bot.py
diff options
context:
space:
mode:
authorChinaman <root@chinaman>2011-09-06 19:47:58 +0200
committerChinaman <root@chinaman>2011-09-06 19:47:58 +0200
commit108f3616e3f4958752d881192ef29e5fc4c2b045 (patch)
tree3c67478c852265219b72e6e1b05467d7065b7ba8 /Reaktor/IRC/bot.py
parentb2d65500160bcdf7abb2bf985f7da582b810e25c (diff)
parentc3bc5a6d16868c121aca780f3109155797b51d76 (diff)
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'Reaktor/IRC/bot.py')
-rwxr-xr-xReaktor/IRC/bot.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/Reaktor/IRC/bot.py b/Reaktor/IRC/bot.py
new file mode 100755
index 00000000..af974f4e
--- /dev/null
+++ b/Reaktor/IRC/bot.py
@@ -0,0 +1,34 @@
+#! /usr/bin/env python2
+
+from irclib import IRC, ServerConnectionError, is_channel
+from sys import exit
+from os import environ as env
+
+host = str(env.get('host', 'irc.freenode.org'))
+port = int(env.get('port', 6667))
+nick = str(env.get('nick', 'crabspasm'))
+channel = str(env.get('channel', '#tincspasm'))
+print '====> irc://%s@%s:%s/%s' % (nick, host, port, channel)
+
+irc = IRC()
+try:
+ client = irc.server().connect(host, port, nick)
+except ServerConnectionError, error:
+ print error
+ exit
+
+def on_connect(connection, event):
+ connection.join(channel)
+ print 'Es passiert...'
+
+def on_join(connection, event):
+ connection.privmsg(channel, 'lol')
+
+def on_disconnect(connection, event):
+ exit
+
+client.add_global_handler('welcome', on_connect)
+client.add_global_handler('join', on_join)
+client.add_global_handler('disconnect', on_disconnect)
+
+irc.process_forever()