示例#1
0
def handle_sioreq(reqobj):
    sid = request.sid
    #print("sioreq", sid, reqobj)
    resobj = posturl("http://localhost:4000/",
                     jsonobj=reqobj,
                     asjson=True,
                     verbose=False)
    socketio.emit("siores", resobj, room=sid, namespace="/")
示例#2
0
 def challengeaction(self, kind, id):
     print(kind, "challenge", id)
     res = posturl(f"https://lichess.org//api/challenge/{id}/{kind}",
                   asjson=True,
                   headers={
                       "Authorization": f"Bearer {self.token}",
                       "Accept": "application/json"
                   })
     print(kind, "challenge response", res)
示例#3
0
 def makemove(self, gameid, uci):
     #print("making move", gameid, uci)
     res = posturl(f"https://lichess.org//api/bot/game/{gameid}/move/{uci}",
                   asjson=True,
                   headers={
                       "Authorization": f"Bearer {self.token}",
                       "Accept": "application/json"
                   })
     print("make move response", res)
示例#4
0
 def challenge(self, username, initial, increment, rated, color):
     ratedstr = "true"
     if not rated:
         ratedstr = "false"
     fields = {
         "variant": self.variant,
         "clock.limit": str(initial),
         "clock.increment": str(increment),
         "rated": ratedstr,
         "color": color
     }
     print("making challenge", fields)
     res = posturl(f"https://lichess.org//api/challenge/{username}",
                   asjson=True,
                   headers={
                       "Authorization": f"Bearer {self.token}",
                       "Accept": "application/json"
                   },
                   fields=fields)
     return res