bricker !
[mikachu/bricker.git] / config.py
1 class ConfigChannel(object):
2
3   def __init__(self, name, password=''):
4     self.name = name
5     self.password = password
6
7 class ConfigServer(object):
8   
9   def __init__(self, host, port=6667):
10     """Create a server for the config, which is part of a network.
11
12     Args:
13       host: The host to connect to for the server
14       port: The port to connect to on the host
15     """
16     self.host = host
17     self.port = port
18
19 class ConfigNetwork(object):
20   
21   def __init__(self, statefile, servers, channels, nickname, realname,
22                nickservpw=None, autocommands=[], reconnect=None, rejoin=None):
23     """Create a network for the config.
24
25     Args:
26       statefile: The name of the file to load/save state
27       servers: A list of ConfigServer objects
28       channels: A list of ConfigChannel objects
29       nickname: A string to use as a nickname
30       realname: A string to use as a real name
31       nickservpw: A string password for the nickserv service, if available
32       autocommands: A list of strings, which are commands to send to the server
33         on connect.
34       reconnect: An optional value to specify the number of seconds to wait
35         before reconnecting.  If not set, it will not reconnect.
36       rejoin: An optional value to specify the number of seconds to wait
37         before rejoining a channel.  If not set, it will not rejoin.
38     """
39     self.statefile = statefile
40     self.servers = servers
41     self.channels = channels
42     self.nickname = nickname
43     self.realname = realname
44     self.nickservpw = nickservpw
45     self.autocommands = autocommands
46     self.reconnect_delay = reconnect
47     self.rejoin_delay = rejoin
48
49 class Config:
50   """Configuration options for the brick bot."""
51
52   networks = [
53       ConfigNetwork(
54           statefile='bricker-oftc.state',
55           servers=[
56               ConfigServer('irc.oftc.net'),
57           ],
58           channels=[
59               ConfigChannel('#bling'),
60           ],
61           nickname='bricker',
62           realname='brickerbot',
63           nickservpw='_br1ck3r_1z_m1n3_',
64           autocommands=[
65           ],
66           reconnect=10,
67           rejoin=5),
68       ]