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="/")
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)
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)
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