Exemplo n.º 1
0
def getApiClient(name):
    settings = getConnection(name)
    if 'token' in settings:
        return screepsapi.API(
            token=settings['token'],
            host=settings['host'],
            secure=settings['secure'],
        )
    else:
        return screepsapi.API(
            u=settings['username'],
            p=settings['password'],
            host=settings['host'],
            secure=settings['secure'],
        )
Exemplo n.º 2
0
 def getScreepsAPI(self):
     if not self.__api:
         settings = getSettings()
         self.__api = screepsapi.API(u=settings['screeps_username'],
                                     p=settings['screeps_password'],
                                     ptr=settings['screeps_ptr'])
     return self.__api
Exemplo n.º 3
0
 def getScreepsAPI(self):
     if not self.__api:
         settings = getSettings()
         self.__api = screepsapi.API(token=settings['screeps_token'],
                                     ptr=settings['screeps_ptr'],
                                     host=settings["host"],
                                     secure=settings["secure"])
     return self.__api
Exemplo n.º 4
0
 def getApiClient(self):
     if not self.apiclient:
         settings = self.getSettings()
         self.apiclient = screepsapi.API(u=settings['screeps_username'],
                                         p=settings['screeps_password'],
                                         ptr=settings['screeps_ptr'],
                                         host=settings['screeps_host'])
     return self.apiclient
Exemplo n.º 5
0
def getScreepsConnection():
    if not getScreepsConnection.sconn:
        settings = config.getSettings()
        getScreepsConnection.sconn = screepsapi.API(
            u=settings['screeps_username'],
            p=settings['screeps_password'],
            ptr=settings['screeps_ptr'])
    return getScreepsConnection.sconn
Exemplo n.º 6
0
def getApiClient(name):
    settings = getConnection(name)
    return screepsapi.API(
        u=settings['username'],
        p=settings['password'],
        host=settings['host'],
        secure=settings['secure'],
    )
Exemplo n.º 7
0
async def screeps(session: CommandSession):
    command = session.current_arg_text.strip().split(" ")
    apii = screepsapi.API(USER, PASSWORD, host="screeps.com", secure=True)
    try:
        num = int(int(command[2]) / 10)
        if num > 6000:
            await session.send('爬爬爬')
            return
        commad = f"Game.tools.give('{command[0]}','{command[1]}',{str(num)})"
        print('------------------------------支援指令=' + commad)
        res = apii.console(commad, shard='shard3')
    except:

        pass
    if apii is not None:
        del apii
    await session.send('ok')
Exemplo n.º 8
0
if not os.path.isfile(path):
    print('no settings file found')
    sys.exit(-1)

with open(path, 'r') as f:
    settings = yaml.load(f)

if 'ptr' not in settings:
    settings['ptr']= None
if 'host' not in settings:
    settings['host']= None

if 'token' in settings:
    screepsclient = screepsapi.API(
                    token=settings['token'],
                    ptr=settings['ptr'],
                    host=settings['host'])
else:
    screepsclient = screepsapi.API(
                    u=settings['username'],
                    p=settings['password'],
                    ptr=settings['ptr'],
                    host=settings['host'])

def api_error_except(api_result):
    if 'error' in api_result:
        raise Exception(api_result['error'])
    return api_result

setattr(screepsclient, "api_error_except", api_error_except)
Exemplo n.º 9
0
def getScreepsAPI():
    settings = getSettings()
    return screepsapi.API(u=settings['screeps_username'],p=settings['screeps_password'],ptr=settings['screeps_ptr'])
Exemplo n.º 10
0
 def getScreepsAPI(self):
     if not self.__api:
         settings = getSettings()
         self.__api = screepsapi.API(token=settings['screeps_token'], ptr=settings['screeps_ptr'])
     return self.__api
Exemplo n.º 11
0
def getScreepsAPI():
    settings = getSettings()
    return screepsapi.API(token=settings['screeps_token'], ptr=settings['screeps_ptr'])