summaryrefslogtreecommitdiffstats
path: root/Synapse/bot.py
blob: af974f4e36a1cebec7fb52d5ce5ce2e91f3a69a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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()