Skip to content

Commit

Permalink
added geoip in the bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandru Stan committed Mar 21, 2010
1 parent 155162e commit 05ce62f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pyscripts/plugins/ircbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import sbserver

from xsbs.players import player
import GeoIp
import string

config = {
Expand Down Expand Up @@ -51,7 +53,7 @@
'irc_message': '${grey}${channel} ${blue}${name}${white}: ${message}',
'status_message': '${num_clients} clients on map ${map_name}',

'player_connect': '${blue}Connected: ${magenta}${name}${white} (${magenta}${cn}${white}) from ${yellow}Country',
'player_connect': '${blue}Connected: ${magenta}${name}${white} (${magenta}${cn}${white}) from ${yellow}${country}',
'player_disconnect': '${blue}Disconnected: ${magenta}${name}${white}',
'message': '${magenta}${name}${white}: ${message}',
'map_change': '${blue}Map: ${magenta}${map} ${yellow}(${mode})',
Expand Down Expand Up @@ -141,7 +143,7 @@ def dotemplate(ability, **args):
factory.broadcast(string.Template(config['Templates'][ability]).substitute(irccolordict, **args))

event_abilities = {
'player_connect': ('player_connect', lambda x: dotemplate('player_connect', name=sbserver.playerName(x), cn=x)),
'player_connect': ('player_connect', lambda x: dotemplate('player_connect', name=sbserver.playerName(x), cn=x, country=GeoIp.getCountry(player(x).ipLong()))),
'player_disconnect': ('player_disconnect', lambda x: dotemplate('player_disconnect', name=sbserver.playerName(x), cn=x)),
'message': ('player_message', lambda x, y: dotemplate('message', name=sbserver.playerName(x), cn=x, message=y)),
'map_change': ('map_changed', lambda x, y: dotemplate('map_change', map=x, mode=sbserver.modeName(y))),
Expand Down

0 comments on commit 05ce62f

Please sign in to comment.