Beispiel #1
0
def servertick(gm,sm):
    try:
        msg = message_queue.get(False)
    except Queue.Empty:
        return
    
    if msg['type'] == 'log':
        acserver.log(msg['text'])
    elif msg['type'] == 'msg':
        acserver.msg(msg['text'], msg['cn'])
        
Beispiel #2
0
def serverext(cn,ext,ext_text):
    global download_thread
    if ext == "getmap":
        if auth.hasPermission(cn, "getMap"):
            maps = ext_text.split()
            acserver.log("AkimboDownloader: Download request from user %s cn(%d), maps: %s"%(auth.AuthenticatedClients[cn].name,cn,",".join(maps)))
            acserver.msg("\f2Attempting to download: %s"%(",".join(maps)),cn)
            
            for m in maps:
                download_queue.put((m,cn))
                
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    
    if ext == "removemap":
        if auth.hasPermission(cn, "rmMap"):
            maps = ext_text.split()
            acserver.log("AkimboDownloader: Delete request from user %s cn(%d), maps: %s"%(auth.AuthenticatedClients[cn].name,cn,",".join(maps)))
            for mapname in maps:
                try:
                    os.remove(os.path.join(local_maps_path,os.path.basename(mapname)+'.cgz'))
                except OSError:
                    acserver.msg("\f3Error deleting %s."%(mapname),cn)
                    acserver.log("AkimboDownloader: Map delete failed %s, full path: %s"%(mapname,os.path.join(local_maps_path,os.path.basename(mapname))))
                    continue
                
                try:
                    os.remove(os.path.join(local_maps_path,os.path.basename(mapname)+'.cfg'))
                except OSError:
                    pass #Its totally normal not to have a cfg
                
                
                acserver.msg("\f2Map %s deleted"%(mapname),cn)
                acserver.log("AkimboDownloader: Deleted map %s"%(mapname))
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
Beispiel #3
0
def serverext(cn,ext,ext_text):
    global enabled
    if ext == "enableLava":
        if auth.hasPermission(cn, "serverOp"):
            enabled = True
            acserver.msg("\f9Lava is enabled!")
            acserver.log("LavaGame: %s enabled lava"%auth.AuthenticatedClients[cn].name)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    
    if ext == "disableLava":
        if auth.hasPermission(cn, "serverOp"):
            enabled = False
            acserver.msg("\f4Lava is disabled!",cn)
            acserver.log("LavaGame: %s disabled lava"%auth.AuthenticatedClients[cn].name)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
Beispiel #4
0
def serverext(cn,ext,ext_text):
    global enabled, clientHealth, nextDamage
    if ext == "enableVampire":
        if auth.hasPermission(cn, "serverOp"):
            enabled = True
            acserver.msg("\f9Vampire is enabled!")
            nextDamage = acserver.getServMillis() + damageInterval
            acserver.log("Vampire: %s enabled vampire"%auth.AuthenticatedClients[cn].name)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    if ext == "disableVampire":
        if auth.hasPermission(cn, "serverOp"):
            enabled = False
            acserver.msg("\f9Vampire is disabled!")
            acserver.log("Vampire: %s disabled vampire"%auth.AuthenticatedClients[cn].name)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
Beispiel #5
0
def serverext(cn,ext,ext_text):
    if ext == 'sendirc':
        if not (auth.hasPermission(cn,'IRCOp') or auth.hasPermission(cn,'IRCController')):
            acserver.msg("\f3You don't have access to that command!",cn)
            return
            
        if len(ext_text.split()) < 2:
            acserver.msg("\f9Invalid arguments to sendirc", cn)
            return
        
        chan,msg = ext_text.split(' ',1)
        acircbot.msg(msg,channel=chan)
        acserver.log("IRCBOT: User %s cn(%d) sent messsage to %s: %s."%(auth.AuthenticatedClients[cn].name,cn, chan, msg),cn)
        
    if ext == 'startirc':
        if not auth.hasPermission(cn,'IRCController'):
            acserver.msg("\f3You don't have access to that command!",cn)
            return
            
        if bot_running:
            acserver.msg("\f3The IRC Bot is already running!",cn)
        else:
            startIRCBot()
            acserver.msg("\f1Attempted startup of IRCBot.",cn)
            acserver.log("IRCBOT: Start command issued by user %s cn(%d)."%(auth.AuthenticatedClients[cn].name,cn),cn)
    
    if ext == 'stopirc':
        if not auth.hasPermission(cn,'IRCController'):
            acserver.msg("\f3You don't have access to that command!",cn)
            return
            
        if not bot_running:
            acserver.msg("\f3The IRC Bot isn't running!",cn)
        else:
            stopIRCBot()
            acserver.msg("\f1IRC bot stopped.",cn)
            acserver.log("IRCBOT: Stop command issued by user %s cn(%d)."%(auth.AuthenticatedClients[cn].name,cn),cn)
Beispiel #6
0
def serverext(session,cn,ext,ext_text):
    if ext == "auth":
        args = ext_text.split()
        if len(args) != 2:
            acserver.msg("\f9Invalid arguments to auth/", cn)
            return
            
        name, pwd = args

        try:
            usr = session.query(db.User).filter(db.User.name==name).one()
        except NoResultFound:
            acserver.msg("\f9Invalid login!",cn)
            return
            
        if usr.checkPassword(pwd):
            AuthenticatedClients[cn] = usr
            acserver.msg("\fJLogin Succeeded!",cn)
            acserver.log("Authenticated client (%d) %s as %s"%(cn,acserver.getClient(cn)['name'],name))
        else:
            acserver.msg("\f9Invalid login!",cn)
        
    if ext == "adduser":
        if hasPermission(cn,'addUser'):
            args = ext_text.split()
            if len(args) != 3:
                acserver.msg("\f9Invalid arguments to register", cn)
                return
        
            name, email, pwd = args
        
            usrcount = session.query(db.User).filter(db.User.name==name).count()
        
            if usrcount:
                acserver.msg("\f9User already exists!",cn)
                session.close()
                return
        
            session.add(db.makeUser(name,pwd,email))
            session.commit()
            acserver.msg("\fJCreated user! Please login now with the credentials you provided.",cn)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    
    if ext == "claimadmin":
        if hasPermission(cn,'serverOp'):
            acserver.setAdmin(cn,1)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    
    if ext == "listusers":
        if hasPermission(cn,'listUsers'):
            acserver.msg("\fHUser List:",cn)
            for usr in session.query(db.User).all():
                if usr.id == AuthenticatedClients[cn].id:
                    acserver.msg("%d) \fQ%s \f5- \fI%s \f5: {\fN%s\f5}"%(usr.id, usr.name,usr.email,"\f5, \fN".join(map(lambda p: p.name, usr.permissions))),cn)
                else:
                    acserver.msg("%d) \fR%s \f5- \fI%s \f5: {\fN%s\f5}"%(usr.id, usr.name,usr.email,"\f5, \fN".join(map(lambda p: p.name, usr.permissions))),cn)
        
            acserver.msg("\fHEnd User List.",cn)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
    
    if ext == "grantperm":
        if hasPermission(cn,'grantPermission'):
            args = ext_text.split()
            if len(args) != 2:
                acserver.msg("\f9Invalid arguments to grantperm", cn)
                return
            
            username,permname = args
        
            try:
                user = db.getUser(session,username)
            except NoResultFound:
                acserver.msg("\f3User not found!",cn)
                return
        
            try:
                perm = db.getPerm(session,permname)
            except NoResultFound:
                acserver.msg("\f3Permission does not exist!",cn)
                return
        
            if perm in user.permissions:
                acserver.msg("\f3User already has that permission!",cn)
                return
            else:
                user.permissions.append(perm)
                session.commit()
                acserver.msg("\fJPermission granted successfully!",cn)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)
Beispiel #7
0
def serverext(cn,ext,ext_text):
    if ext == "tps":
        if auth.hasPermission(cn, "useTPS"):
            acserver.msg("\fBCurrent TPS: \f9%d\fB, Average: \f9%.2f"%(mpt_to_tps(mpt_last),mpt_to_tps(float(mpt_total)/mpt_count)),cn)
        else:
            acserver.msg("\f3You don't have access to that command!",cn)