Skip to content

Commit

Permalink
Add irc color dict, irc templates and fix features
Browse files Browse the repository at this point in the history
  • Loading branch information
darkf committed Mar 21, 2010
1 parent 4fd0307 commit b60ab89
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions src/pyscripts/plugins/ircbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

config = {
'Main': {
'enable': 'yes',
'enable': 'no',
'part_message': 'XSBS - eXtensible SauerBraten Server',
'ipaddress': '0',
},
Expand All @@ -24,7 +24,15 @@
'channel': '#xsbs-newserver'
},
'Features': {
'message_gateway': 'yes'
'message_gateway': 'yes',
'player_disconnect': 'yes',
'player_connect': 'yes',
'message': 'yes',
'map_change': 'yes',
'gain_admin': 'yes',
'gain_master': 'yes',
'relinquish_master': 'yes',
'relinquish_admin': 'yes'
},
'Alerts': {
'player_connect': 'yes',
Expand All @@ -41,9 +49,41 @@
'Templates': {
'irc_message': '${grey}${channel} ${blue}${name}${white}: ${message}',
'status_message': '${num_clients} clients on map ${map_name}',

'player_connect': '${magenta}${name}${white} connected',
'player_disconnect': '${magenta}${name}${white} disconnected',
'message': '${magenta}${name}${white}: ${message}',
'map_change': 'map change: ${map}',
'gain_admin': '${magenta}${name}${white} has claimed admin',
'gain_master': '${magenta}${name}${white} has claimed master',
'auth': '${magenta}${name}${white} has authenticated as ${authname}@sauerbraten.org',
'relinquish_admin': '${magenta}${white} has relinquished admin',
'relinquish_master': '${magenta}${white} has relinquished master'
}
}

irccolordict = {
'black': '\x030',
'red': '\x031',
'green': '\x032',
'yellow': '\x033',
'blue': '\x034',
'magenta': '\x035',
'cyan': '\x036',
'white': '\x037',
'default': '\x039',

'bgblack': '\x040',
'bgred': '\x041',
'bggreen': '\x042',
'bgyellow': '\x043',
'bgblue': '\x044',
'bgmagenta': '\x045',
'bgcyan': '\x046',
'bgwhite': '\x047',
'bgdefault': '\x049',
}

class IrcBot(irc.IRCClient):
def connectionMade(self):
self.nickname = self.factory.nickname
Expand Down Expand Up @@ -77,10 +117,10 @@ def __init__(self, nickname, channels):
self.bots = []
self.reconnect_count = 0
def doConnect(self):
if config['Main']['ipaddress'] == '0':
if ipaddress == '0':
reactor.connectTCP(config['Connection']['server'], int(config['Connection']['port']), factory)
else:
reactor.connectTCP(config['Connection']['server'], int(config['Connection']['port']), factory, 30, (config['Main']['ipaddress'], 0))
reactor.connectTCP(config['Connection']['server'], int(config['Connection']['port']), factory, 30, (config['Connection']['ipaddress'], 0))
def doReconnect(self):
if self.reconnect_count < 5:
self.reconnect_count += 1
Expand Down

0 comments on commit b60ab89

Please sign in to comment.