예제 #1
0
파일: game.py 프로젝트: mmartin/ogs_api
def game_chat(game_id, message, move_number, type="main"):
    data = get_data()
    comm_socket.emit("game/chat", data={"game_id": game_id,
                                        "player_id": data["user"]["id"],
                                        "type": type,
                                        "body": message,
                                        "move_number": move_number
                                        })
예제 #2
0
def _chat_connect():
    from ogs_api.access_tokens import get_data, get_chat_auth
    data = get_data()
    global _user_id
    _user_id = data['user']['id']
    comm_socket.emit("chat/connect", data={"auth": get_chat_auth(),
                                           "player_id": data["user"]["id"],
                                           "ranking": data["user"]["ranking"],
                                           "username": data["user"]["username"],
                                           "ui_class": data["user"]["ui_class"]})
예제 #3
0
def pm_send(username: str, message: str):
    try:
        player_id = _name2id_cache[username]
    except KeyError:
        results = access_api('/api/v1/players', params={'username': username})
        assert results['count'] == 1
        player_id = results['results'][0]['id']
        _name2id_cache[username] = player_id

    private_chat = _private_chat_cache[player_id]
    private_chat.number += 1

    comm_socket.emit('chat/pm', {
        'player_id': player_id,
        'username': username,
        'uid': private_chat.base + '.' + _n2s(private_chat.number),
        'message': message,
    })
예제 #4
0
def chat_send(channel: str, message: str):
    comm_socket.emit("chat/send", data={
        'channel': channel,
        'uuid': _n2s(_user_id) + '.' + _n2s(int(time.time() * 1000)),
        'message': message,
    })
예제 #5
0
def chat_part(channel: str):
    comm_socket.emit("chat/part", data={"channel": channel})
예제 #6
0
def chat_join(channel: str):
    comm_socket.emit("chat/join", data={"channel": channel})
예제 #7
0
파일: game.py 프로젝트: mmartin/ogs_api
def game_connect(game_id, connect_to_gamechat=0):
    data = get_data()
    comm_socket.emit("game/connect", data={"game_id": game_id,
                                           "player_id": data["user"]["id"],
                                           "chat": connect_to_gamechat})
예제 #8
0
파일: game.py 프로젝트: mmartin/ogs_api
def game_resume(game_id):
    data = get_data()
    comm_socket.emit("game/resume", data={"game_id": game_id,
                                          "player_id": data["user"]["id"]})
예제 #9
0
파일: game.py 프로젝트: mmartin/ogs_api
def game_pass(game_id):
    data = get_data()
    comm_socket.emit("game/move", data={"game_id": game_id,
                                        "player_id": data["user"]["id"],
                                        "move": ".."})
예제 #10
0
파일: game.py 프로젝트: mmartin/ogs_api
def game_disconnect(game_id):
    comm_socket.emit("game/disconnect", data={"game_id": game_id})