#Backwards compatibility with non Python versions of ES
from usermsg import *

def load():
    if es.exists('command','usermsg') == 0:
        es.regcmd('usermsg','corelib/usermsglib/usermsgcmd','Corelib command: usermsg used as a shortcut for es_usermsg')

def usermsgcmd():
    argc = es.getargc()
    subcommand=es.getargv(1)
    userid=es.getargv(2)
    if subcommand == 'list':
        list()
    elif subcommand == 'fade':
        if argc >= 10:
          fade(userid,es.getargv(3),es.getargv(4),es.getargv(5),es.getargv(6),es.getargv(7),es.getargv(8),es.getargv(9))
        else:
          es.dbgmsg(0,"Usermsglib.py: fade: Syntax: fade <userid> <0 = no fade, 1 = fade Out 2 = fade in> <time to fade (in frames)> <time faded (in frames)> <red> <green> <blue> <alpha>")
    elif subcommand == 'shake':
        if argc >= 5:
          shake(userid,es.getargv(3),es.getargv(4))
        else:
          es.dbgmsg(0,"Usermsglib.py: shake: Syntax: shake <userid> <magnitude> <time>")
    elif subcommand == 'motd':
        if argc >= 6:
          motd(userid,es.getargv(3),es.getargv(4),es.getargv(5))
        else:
          es.dbgmsg(0,"Usermsglib.py: motd: Syntax: motd <userid> <0 = text, 2 = url> <title> <msg>")
    elif subcommand == 'hudhint':
        if argc >= 4:
          hudhint(userid,es.getargv(3))
        else:
          es.dbgmsg(0,"Usermsglib.py: hudhint: Syntax: hudhint <userid> <msg>")
    elif subcommand == 'centermsg':
        if argc >= 4:
          centermsg(userid,es.getargv(3))
        else:
          es.dbgmsg(0,"Usermsglib.py: centermsg: Syntax: centermsg <userid> <msg>")
    elif subcommand == 'echo':
        if argc >= 4:
          echo(userid,es.getargv(3))
        else:
          es.dbgmsg(0,"Usermsglib.py: echo: Syntax: echo <userid> <msg>")
    else:
        es.dbgmsg(0,"Usermsglib.py: Invalid subcommand, type \"usermsg list\" to see a list of valid subcommands")
