forked from mushorg/buttinsky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuttinsky.py
50 lines (36 loc) · 1.62 KB
/
buttinsky.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# Copyright (C) 2012 Buttinsky Developers.
# See 'COPYING' for copying permission.
from configobj import ConfigObj
from event_loops import gevent_client
from protocols import irc
from behaviors import simple_response
from modules import reporter_handler
from stack import Layer
buttinsky_config = ConfigObj("conf/buttinsky.cfg")
class Buttinsky(object):
def __init__(self):
pass
if __name__ == "__main__":
#gevent.signal(signal.SIGQUIT, gevent.shutdown)
net_settings = ConfigObj("settings/freenode.set", _inspec=True)
set_nick = "NICK %s\r\n" % net_settings["nick"]
set_user = "USER %s %s bla :%s\r\n" % (net_settings["nick"],
net_settings["host"],
net_settings["nick"],
)
net_settings["hello"] = set_nick + set_user
client = gevent_client.Client(net_settings["host"],
net_settings["port"],
net_settings["connection_protocol_type"])
# layer_network <-> layer_log <-> layer_protocol <-> layer_behavior
layer_network = Layer(gevent_client.Layer1(client))
layer_log = Layer(reporter_handler.ReporterHandler(), layer_network)
layer_protocol = Layer(irc.IRCProtocol(), layer_log)
layer_behavior = Layer(simple_response.SimpleResponse(), layer_protocol)
layer_protocol.settings(net_settings)
layer_network.setUpper(layer_log)
layer_log.setUpper(layer_protocol)
layer_protocol.setUpper(layer_behavior)
client.setLayer1(layer_network)
client.connect()