def cmd_statsme(userid,args): if str(userid) in xs.pending: es.tell(userid,txt.getSimple('messages','sorry_pending')) return steamid = es.getplayersteamid(userid) methods_used = [] toprank = None lowrank = None refresh = True for method in xs.methods: rank,score,allplayers = xs.getRankScore(steamid,method,refresh) refresh = False # if toprank is None OR rank is smaller (smaller number = higher rank) than toprank if not toprank or rank < toprank[0]: toprank = (rank,score,method) if not lowrank or rank > lowrank[0]: lowrank = (rank,score,method) methods_used.append(toprank[2]) methods_used.append(lowrank[2]) defaultmethod = xs.getMethod() defaultrank,defaultscore = None,None if defaultmethod not in methods_used: defaultrank,defaultscore,allplageyers = xs.getRankScore(steamid,defaultmethod,refresh) refresh = False methods_used.append(defaultmethod) personalrank,personalscore = None,None settings_method = xs.players.query(steamid,'settings_method') if settings_method in xs.methods.keys() and settings_method not in methods_used: personalrank,personalscore,allplayers = xs.getRankScore(steamid,settings_method,refresh) refresh = False methods_used.append(settings_method) pplchck('xs_statshim_%s' % userid) statshim = popuplib.easylist('xs_statshim_%s' % userid) statshim.settitle(text.getSimple('statsme','title')) if defaultrank: statshim.additem(text.getCmdString(steamid,'statsme',xs.dcfg['default_method'],defaultscore,defaultrank,allplayers)) if personalrank: statshim.additem(text.getCmdString(steamid,'statsme',settings_method,personalscore,personalrank,allplayers)) statshim.additem(text.getCmdString(steamid,'statsme_toprank',toprank[2],toprank[1],toprank[0],allplayers)) statshim.additem(text.getCmdString(steamid,'statsme_lowrank',lowrank[2],lowrank[1],lowrank[0],allplayers)) if bool(xs.dcfg['statsme_methods']): mlist = xs.dcfg.as_list('statsme_methods') for method in filter(lambda x: (x in xs.methods or x in xs.players.columns) and x not in methods_used,mlist): methods_used.append(method) rank,score,allplayers = xs.getRankScore(steamid,method,refresh) refresh = False statshim.additem(text.getCmdString(steamid,'statsme',method,score,rank,allplayers)) statshim.send(userid)
def cmd_rank(userid,args): if str(userid) in xs.pending: es.tell(userid,txt.getSimple('messages','sorry_pending')) return steamid = es.getplayersteamid(userid) if len(args) == 1: method = xs.getMethod(args[0].lower()) else: method = xs.getMethod(xs.players.query(steamid,'settings_method')) rank,score,totalplayers = xs.getRankScore(steamid,method, True) es.tell(userid,text.getCmdString(steamid,'rank',method,score,rank,totalplayers))