This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgg_lib.py
76 lines (58 loc) · 1.45 KB
/
gg_lib.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import yaml
def std_send_command(name_c, name_p, name_pl, param_c = None):
"""
Standardise l'émission des commandes
Params :
string name_c => nom commande
string name_p => nom joueur
string name_pl => nom plateforme
dict param_c => les paramètres de la commande
Return:
string
"""
res = dict()
res["name_c"] = name_c
res["name_p"] = name_p
res["name_pl"] = name_pl
if param_c != None :
res["param_c"] = param_c
return str(res)
def std_receive_command(send):
"""
Standardise la réception des commandes
Params :
string send => Mettre socket.recv()
Return :
Dict
"""
return yaml.safe_load(send)
# def std_log(type = "INFO", str):
# """
# ||| WIP |||
# Ecrit les log
#
# params:
# str type => ERROR ,WARNING ,INFO
# str str => message a affiché
#
# return:
# str res => [hh:mm:ss] TYPE : str
# """
def std_answer_command(name_c, name_p, name_pl, msg = None):
"""
Standardise la réponse du serveur au client.
params :
str name_c => nom de la commande
str name_p => nom du joueur
str name_pl => nom de la plateforme de DESTINATION
str msg => message a afficher
Return :
string
"""
res = dict()
res["name_c"] = name_c
res["name_p"] = name_p
res["name_pl"] = name_pl
if msg != None :
res["msg"] = msg
return str(res)