Пример #1
0
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
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
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
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
def game_disconnect(game_id):
    comm_socket.emit("game/disconnect", data={"game_id": game_id})