def player_connect(event_var):
    """ Announces the connecting player's country """
    if event_var['networkid'] == 'BOT':
        return

    tokens = {
        'name': event_var['name'],
        'location': iptocountry.get_country(event_var['address'])[0]
    }
    chat = int(cvar_announce_chat)
    center = int(cvar_announce_center)
    hud = int(cvar_announce_hud)

    es.dbgmsg(0, remove_tags(lang_text('connect', tokens)))

    for userid in es.getUseridList():
        text = lang_text('connect', tokens,
                         playerlib.getPlayer(userid).get('lang'))

        if chat:
            if chat == 2:
                es.tell(userid, '#multi', text)
            else:
                usermsg.echo(userid, remove_tags(text))
        if center:
            es.centertell(userid, remove_tags(text))
        if hud:
            usermsg.hudhint(userid, remove_tags(text))
def country_cmd(args):
   """
   iptocountry_getcountry <country var> <abbr var> <"ip">
   Returns the country name and three-letter abbreviation associated with the IP to server variables
   """
   if len(args) == 3:
      info = iptocountry.get_country(args[2])

      es.ServerVar(args[0]).set(info[0])
      es.ServerVar(args[1]).set(info[1])

   else:
      es.dbgmsg(0, 'Syntax: iptocountry_getcountry <country var> <abbr var> <"ip">')
def country_cmd(args):
    """
   iptocountry_getcountry <country var> <abbr var> <"ip">
   Returns the country name and three-letter abbreviation associated with the IP to server variables
   """
    if len(args) == 3:
        info = iptocountry.get_country(args[2])

        es.ServerVar(args[0]).set(info[0])
        es.ServerVar(args[1]).set(info[1])

    else:
        es.dbgmsg(
            0,
            'Syntax: iptocountry_getcountry <country var> <abbr var> <"ip">')
def player_connect(event_var):
   """ Announces the connecting player's country """
   if event_var['networkid'] == 'BOT':
      return

   tokens = {'name': event_var['name'], 'location': iptocountry.get_country(event_var['address'])[0]}
   chat   = int(cvar_announce_chat)
   center = int(cvar_announce_center)
   hud    = int(cvar_announce_hud)

   es.dbgmsg(0, remove_tags(lang_text('connect', tokens)))

   for userid in es.getUseridList():
      text = lang_text('connect', tokens, playerlib.getPlayer(userid).get('lang'))

      if chat:
         if chat == 2:
            es.tell(userid, '#multi', text)
         else:
            usermsg.echo(userid, remove_tags(text))
      if center:
         es.centertell(userid, remove_tags(text))
      if hud:
         usermsg.hudhint(userid, remove_tags(text))