hungerlib 3.2.dev9__py3-none-any.whl → 3.2.dev10__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hungerlib/messagerouter.py +5 -39
- {hungerlib-3.2.dev9.dist-info → hungerlib-3.2.dev10.dist-info}/METADATA +1 -1
- {hungerlib-3.2.dev9.dist-info → hungerlib-3.2.dev10.dist-info}/RECORD +6 -6
- {hungerlib-3.2.dev9.dist-info → hungerlib-3.2.dev10.dist-info}/WHEEL +0 -0
- {hungerlib-3.2.dev9.dist-info → hungerlib-3.2.dev10.dist-info}/licenses/LICENSE +0 -0
- {hungerlib-3.2.dev9.dist-info → hungerlib-3.2.dev10.dist-info}/top_level.txt +0 -0
hungerlib/messagerouter.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import inspect
|
|
2
1
|
import logging
|
|
3
2
|
from pathlib import Path
|
|
4
3
|
from datetime import datetime
|
|
5
|
-
from hungerlib.utils.colormaps import ASCII_COLOR_MAP, MC_COLOR_MAP
|
|
6
|
-
from hungerlib.datamap import DataMap, Syntax, mapit
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
class MessageRouter:
|
|
10
6
|
def __init__(
|
|
@@ -15,11 +11,6 @@ class MessageRouter:
|
|
|
15
11
|
formatter=None,
|
|
16
12
|
console_backspaces=0,
|
|
17
13
|
|
|
18
|
-
origin_map=ASCII_COLOR_MAP,
|
|
19
|
-
destination_map=ASCII_COLOR_MAP,
|
|
20
|
-
broadcast_map=MC_COLOR_MAP,
|
|
21
|
-
log_map=None,
|
|
22
|
-
|
|
23
14
|
info_prefix="<white>[INFO]: ",
|
|
24
15
|
warn_prefix="<yellow>[WARN]: ",
|
|
25
16
|
error_prefix="<red>[ERROR]: "
|
|
@@ -33,11 +24,6 @@ class MessageRouter:
|
|
|
33
24
|
|
|
34
25
|
self.console_backspaces = "\b" * console_backspaces
|
|
35
26
|
|
|
36
|
-
self._origin_map = origin_map
|
|
37
|
-
self._destination_map = destination_map
|
|
38
|
-
self._broadcast_map = broadcast_map
|
|
39
|
-
self._log_map = log_map
|
|
40
|
-
|
|
41
27
|
self.info_prefix = info_prefix
|
|
42
28
|
self.warn_prefix = warn_prefix
|
|
43
29
|
self.error_prefix = error_prefix
|
|
@@ -57,47 +43,27 @@ class MessageRouter:
|
|
|
57
43
|
handler.setFormatter(formatter)
|
|
58
44
|
self.logger.addHandler(handler)
|
|
59
45
|
|
|
60
|
-
#
|
|
61
|
-
def setOriginMap(self, cmap): self._origin_map = cmap
|
|
62
|
-
def getOriginMap(self): return self._origin_map
|
|
63
|
-
|
|
64
|
-
def setDestinationMap(self, cmap): self._destination_map = cmap
|
|
65
|
-
def getDestinationMap(self): return self._destination_map
|
|
66
|
-
|
|
67
|
-
def setBroadcastMap(self, cmap): self._broadcast_map = cmap
|
|
68
|
-
def getBroadcastMap(self): return self._broadcast_map
|
|
69
|
-
|
|
70
|
-
def setLogMap(self, cmap): self._log_map = cmap
|
|
71
|
-
def getLogMap(self): return self._log_map
|
|
72
|
-
|
|
73
|
-
# routing primatives
|
|
46
|
+
# routing primitives
|
|
74
47
|
def origin(self, msg):
|
|
75
|
-
|
|
76
|
-
print(colored)
|
|
48
|
+
print(msg)
|
|
77
49
|
|
|
78
50
|
def destination(self, msg):
|
|
79
51
|
if not self.server or not hasattr(self.server, "_rcon_send"):
|
|
80
52
|
return
|
|
81
|
-
colored = mapit(msg, self._destination_map)
|
|
82
53
|
self.server._rcon_send(
|
|
83
|
-
f'logtellraw targetless "{self.console_backspaces}{
|
|
54
|
+
f'logtellraw targetless "{self.console_backspaces}{msg}"'
|
|
84
55
|
)
|
|
85
56
|
|
|
86
57
|
def log(self, msg, level="INFO"):
|
|
87
|
-
clean = msg
|
|
88
|
-
if self._log_map:
|
|
89
|
-
for tag in self._log_map.as_dict().keys():
|
|
90
|
-
clean = clean.replace(tag, "")
|
|
91
58
|
{
|
|
92
59
|
"INFO": self.logger.info,
|
|
93
60
|
"WARN": self.logger.warning,
|
|
94
61
|
"ERROR": self.logger.error
|
|
95
|
-
}[level](
|
|
62
|
+
}[level](msg)
|
|
96
63
|
|
|
97
64
|
def broadcast(self, msg):
|
|
98
65
|
if hasattr(self.server, "sendBroadcast"):
|
|
99
|
-
|
|
100
|
-
self.server.sendBroadcast(colored)
|
|
66
|
+
self.server.sendBroadcast(msg)
|
|
101
67
|
|
|
102
68
|
# high level router
|
|
103
69
|
def say(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
hungerlib/__init__.py,sha256=CTLIet8Tg8Gx3wWUrUNgIsHutv0JS1YzLelp1GLaLTs,2147
|
|
2
2
|
hungerlib/configloader.py,sha256=TdEFqk2zG5nT-vJqdjA36DrbRinY66n0rgI8Z-EZmAk,2548
|
|
3
3
|
hungerlib/datamap.py,sha256=Tvcjc-n-tNO9SNQeh0k3dWzbxrRnnNVUmPnq0gap_8w,2807
|
|
4
|
-
hungerlib/messagerouter.py,sha256=
|
|
4
|
+
hungerlib/messagerouter.py,sha256=_Exn3zzwdnHCSDt8bvdCylq9atvhAyOK32a9TySKQCU,3098
|
|
5
5
|
hungerlib/panel.py,sha256=LljDy3FZoabWotdrNhN89xHd2VcvbiQDshtZgMa0g08,2013
|
|
6
6
|
hungerlib/api/__init__.py,sha256=xuPbWBXVTkr9Jtcmvk8PPiVvi8HDxrIOmb_gOcDZy-M,336
|
|
7
7
|
hungerlib/api/backups.py,sha256=eJEaCot9QpyvaqB3qne6e94CYmjJahj9Tf9r8ogUQr0,642
|
|
@@ -17,8 +17,8 @@ hungerlib/utils/__init__.py,sha256=xyUldIwkVopZrp0Yp5g18vqGDUp3OOT4KknntLU4oes,5
|
|
|
17
17
|
hungerlib/utils/colormaps.py,sha256=88eIDSI1hZYbtXmd7XujgmR1nhOXAkyB8ospQTqSHns,1240
|
|
18
18
|
hungerlib/utils/time.py,sha256=lhLHMkL5NEP9f7j5k24k5brr1ZvAL22t07eV2rxTZ50,2354
|
|
19
19
|
hungerlib/utils/utils.py,sha256=rGVXiK-ZaN1riNL_1QHKJZdOAX53vGlSDUzEP1Aqle4,1404
|
|
20
|
-
hungerlib-3.2.
|
|
21
|
-
hungerlib-3.2.
|
|
22
|
-
hungerlib-3.2.
|
|
23
|
-
hungerlib-3.2.
|
|
24
|
-
hungerlib-3.2.
|
|
20
|
+
hungerlib-3.2.dev10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
21
|
+
hungerlib-3.2.dev10.dist-info/METADATA,sha256=IW8CwHOl0HJabmx0VdqIGLQtqu0djU8ZFEH5Hz-tfUg,1536
|
|
22
|
+
hungerlib-3.2.dev10.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
23
|
+
hungerlib-3.2.dev10.dist-info/top_level.txt,sha256=uHBMIM8b2Gt6daNkDF4uw-M2Hm2IpIVw1jOK9wC0fNQ,10
|
|
24
|
+
hungerlib-3.2.dev10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|