From 33bd7d44618255ba2b32591b3516e1cdad173d6a Mon Sep 17 00:00:00 2001 From: motoiro <153475888+motoiro@users.noreply.github.com> Date: Tue, 9 Apr 2024 18:02:13 +0800 Subject: [PATCH 1/7] Fixed the problem of playing cards too fast at the beginning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复做庄打牌太快的问题 --- action.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/action.py b/action.py index 5f8ceff..4c3525b 100644 --- a/action.py +++ b/action.py @@ -299,6 +299,8 @@ def mjai2action(self, mjai_msg: dict | None, tehai: list[str], tsumohai: str | N if isliqi: # if someone reached dahai_delay = dahai_delay # Change value here + elif self.isNewRound: + dahai_delay = random.uniform(self.new_min, self.new_max) elif not mjai_msg['tsumogiri']: if mjai_msg['pai'] in YAOJIU: dahai_delay = dahai_delay @@ -324,4 +326,4 @@ def mjai2action(self, mjai_msg: dict | None, tehai: list[str], tsumohai: str | N time.sleep(2) self.click_chiponkan(mjai_msg, tehai, tsumohai) # kan can have multiple candidates too! ex: tehai=1111m 1111p 111s 11z, tsumohai=1s - \ No newline at end of file + From 7b4632db7942010f6ff616de8f07f2daca9ed6de Mon Sep 17 00:00:00 2001 From: shinkuan Date: Tue, 9 Apr 2024 23:45:59 +0800 Subject: [PATCH 2/7] KeyError in autoplay method --- client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client.py b/client.py index e966b02..59ca066 100644 --- a/client.py +++ b/client.py @@ -399,7 +399,10 @@ def redo_action(self) -> None: def autoplay(self) -> None: isliqi = self.isLiqi - self.action.mjai2action(self.app.mjai_msg_dict[self.flow_id][-1], self.tehai, self.tsumohai, isliqi, False) + try: + self.action.mjai2action(self.app.mjai_msg_dict[self.flow_id][-1], self.tehai, self.tsumohai, isliqi, False) + except KeyError: + return self.isLiqi = False if self.dahai_verfication_job is not None: self.dahai_verfication_job.stop() From 37eca9bb1b444c3af7107fbba253b498599c48ff Mon Sep 17 00:00:00 2001 From: Nanako <56375835+ElainaFanBoy@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:42:43 +0800 Subject: [PATCH 3/7] Update my_logger.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 替换CDN域名 --- my_logger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/my_logger.py b/my_logger.py index 140a5ce..ca87895 100644 --- a/my_logger.py +++ b/my_logger.py @@ -18,7 +18,7 @@ def my_sink(message: loguru.Message) -> None: # logger.add(my_sink) RECORD_LOG_FIELDS = set((LogFields.record_name, LogFields.level)) -res = requests.get("https://cdn.jsdelivr.net/gh/shinkuan/RandomStuff/aliyun_log_handler_arg.json", allow_redirects=True) +res = requests.get("https://fastly.jsdelivr.net/gh/shinkuan/RandomStuff/aliyun_log_handler_arg.json", allow_redirects=True) json_data = json.loads(res.content) handler = QueuedLogHandler( From 3dfd9d8467151416add3df7439dd5d57f56e49aa Mon Sep 17 00:00:00 2001 From: Nanako <56375835+ElainaFanBoy@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:44:11 +0800 Subject: [PATCH 4/7] Update simple_client.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 替换CDN域名 --- simple_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simple_client.py b/simple_client.py index 9945205..90080f6 100644 --- a/simple_client.py +++ b/simple_client.py @@ -152,11 +152,11 @@ def request(self, flow: mitmproxy.http.HTTPFlow): print("====== GET code.js ======"*3) print("====== GET code.js ======"*3) print("====== GET code.js ======"*3) - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" elif re.search(r'^https://game\.mahjongsoul\.com/v[0-9\.]+\.w/code\.js$', flow.request.url): - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" elif re.search(r'^https://mahjongsoul\.game\.yo-star\.com/v[0-9\.]+\.w/code\.js$', flow.request.url): - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" async def start_proxy(host, port, enable_unlocker): opts = options.Options(listen_host=host, listen_port=port) From 6d01379eb1fdd2450b15c0e44c564df871eb510e Mon Sep 17 00:00:00 2001 From: Nanako <56375835+ElainaFanBoy@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:44:51 +0800 Subject: [PATCH 5/7] Update mitm.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 替换CDN域名 --- mitm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mitm.py b/mitm.py index 04be0e0..73c3b30 100644 --- a/mitm.py +++ b/mitm.py @@ -57,11 +57,11 @@ def request(self, flow: mitmproxy.http.HTTPFlow): print("====== GET code.js ======"*3) print("====== GET code.js ======"*3) print("====== GET code.js ======"*3) - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" elif re.search(r'^https://game\.mahjongsoul\.com/v[0-9\.]+\.w/code\.js$', flow.request.url): - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" elif re.search(r'^https://mahjongsoul\.game\.yo-star\.com/v[0-9\.]+\.w/code\.js$', flow.request.url): - flow.request.url = "http://cdn.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" + flow.request.url = "http://fastly.jsdelivr.net/gh/Avenshy/majsoul_mod_plus/safe_code.js" async def start_proxy(host, port, enable_unlocker): opts = options.Options(listen_host=host, listen_port=port) From b8c8eac75721b5d855f14ca2df0171d2d8649d4e Mon Sep 17 00:00:00 2001 From: shinkuan Date: Thu, 2 May 2024 11:45:22 +0800 Subject: [PATCH 6/7] update resver --- resver.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resver.json b/resver.json index 4ba492b..2341654 100644 --- a/resver.json +++ b/resver.json @@ -1 +1 @@ -{"version": "0.11.28.w", "emotes": {"200001": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 983, 984, 996, 997], "200002": [10, 11, 12, 14, 15, 16, 17, 18, 888, 995, 998], "200003": [10, 11, 12, 14, 15, 16, 17, 18, 888, 959, 979, 999], "200004": [10, 11, 12, 14, 15, 16, 17, 18, 888, 957, 986, 994, 999], "200005": [10, 11, 12, 14, 15, 16, 17, 18, 888, 968, 989, 997], "200006": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 977, 997], "200007": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 970, 976, 993, 999], "200008": [10, 11, 12, 14, 15, 16, 17, 18, 888, 972, 991, 997], "200009": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 994, 998], "200010": [10, 11, 12, 14, 15, 16, 17, 18, 888, 965, 982], "200011": [10, 11, 12, 14, 15, 16, 17, 18, 888, 970, 977, 998], "200012": [10, 11, 12, 14, 15, 16, 17, 18, 888, 959, 998], "200013": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 988, 999], "200014": [10, 11, 12, 14, 15, 16, 17, 18, 888, 969, 982, 993], "200015": [10, 11, 12, 14, 15, 16, 17, 18, 888, 994], "200016": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 970, 988, 996], "200017": [10, 11, 12, 14, 15, 16, 17, 18, 888, 962, 982, 995], "200018": [9, 10, 11, 12, 14, 15, 16, 17, 18, 888, 962, 994], "200019": [9, 10, 11, 12, 14, 15, 16, 17, 18, 888, 972, 981, 986], "200020": [10, 11, 12, 14, 888, 967, 988, 994], "200021": [10, 11, 12, 14, 888, 954, 981, 985], "200022": [10, 11, 12, 14, 888, 991], "200023": [10, 11, 12, 14, 888, 955, 981], "200024": [10, 11, 12, 14, 888, 960, 976, 992], "200025": [10, 11, 12, 14, 888, 957, 982], "200026": [10, 11, 12, 14, 888, 973, 989], "200027": [10, 11, 12, 14, 888, 968, 988], "200028": [10, 11, 12, 14, 888, 971, 991], "200029": [10, 11, 12, 14, 888, 964, 976, 992], "200030": [10, 11, 12, 14, 888, 955, 979], "200031": [10, 11, 12, 14, 888, 959, 978], "200032": [10, 11, 12, 14, 888, 957, 976, 985], "200033": [10, 11, 12, 14, 888, 969], "200034": [10, 11, 12, 14, 969, 990], "200035": [10, 11, 12, 14, 969, 990], "200036": [10, 11, 12, 14, 969, 990], "200037": [10, 11, 12, 14, 969, 990], "200038": [10, 11, 12, 14, 888, 959, 967, 974], "200039": [10, 11, 12, 14, 888, 961, 970], "200040": [10, 11, 12, 14, 987], "200041": [10, 11, 12, 14, 987], "200042": [10, 11, 12, 14, 987], "200043": [10, 11, 12, 14, 987], "200044": [10, 11, 12, 14, 888, 960, 978], "200045": [10, 11, 12, 14, 888, 973, 981], "200046": [10, 11, 12, 14, 888, 967], "200047": [10, 11, 12, 14, 888, 957, 967], "200048": [10, 11, 12, 14, 888, 965, 971], "200049": [10, 11, 12, 14, 888, 954, 964], "200050": [10, 11, 12, 14, 980], "200051": [10, 11, 12, 14, 980], "200052": [10, 11, 12, 14, 888], "200053": [10, 11, 12, 14, 888, 958], "200054": [10, 11, 12, 14, 888, 953, 974], "200055": [10, 11, 12, 14, 975], "200056": [10, 11, 12, 14, 975], "200057": [10, 11, 12, 14, 975], "200058": [10, 11, 12, 14, 975], "200059": [10, 11, 12, 14, 888, 955, 960], "200060": [10, 11, 12, 14, 888, 958], "200061": [10, 11, 12, 14, 888], "200062": [10, 11, 12, 14, 969], "200063": [10, 11, 12, 14, 969], "200064": [10, 11, 12, 14, 969], "200065": [10, 11, 12, 14, 969], "200066": [10, 11, 12, 14, 888, 955, 962], "200067": [10, 11, 12, 14, 888, 954], "200068": [10, 11, 12, 14, 888, 955], "200069": [10, 11, 12, 14, 888, 953], "200070": [10, 11, 12, 14, 963], "200071": [10, 11, 12, 14, 963], "200072": [10, 11, 12, 14, 963], "200073": [10, 11, 12, 14, 963], "200074": [10, 11, 12, 14, 888], "200075": [10, 11, 12, 14, 888], "200076": [10, 11, 12, 14, 888], "200077": [10, 11, 12, 14, 888, 953], "200078": [10, 11, 12, 14, 888], "200079": [10, 11, 12, 956], "200080": [10, 11, 12, 956], "200081": [10, 11, 12, 956], "200082": [10, 11, 12, 956], "200083": [10, 11, 12, 888], "200084": [10, 11, 12, 888], "200085": [10, 11, 12, 888], "200090": [10, 11, 12, 888]}} \ No newline at end of file +{"version": "0.11.40.w", "emotes": {"200001": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 983, 984, 996, 997], "200002": [10, 11, 12, 14, 15, 16, 17, 18, 888, 952, 995, 998], "200003": [10, 11, 12, 14, 15, 16, 17, 18, 888, 959, 979, 999], "200004": [10, 11, 12, 14, 15, 16, 17, 18, 888, 957, 986, 994, 999], "200005": [10, 11, 12, 14, 15, 16, 17, 18, 888, 952, 968, 989, 997], "200006": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 977, 997], "200007": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 970, 976, 993, 999], "200008": [10, 11, 12, 14, 15, 16, 17, 18, 888, 972, 991, 997], "200009": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 994, 998], "200010": [10, 11, 12, 14, 15, 16, 17, 18, 888, 965, 982], "200011": [10, 11, 12, 14, 15, 16, 17, 18, 888, 970, 977, 998], "200012": [10, 11, 12, 14, 15, 16, 17, 18, 888, 959, 998], "200013": [10, 11, 12, 14, 15, 16, 17, 18, 888, 966, 988, 999], "200014": [10, 11, 12, 14, 15, 16, 17, 18, 888, 969, 982, 993], "200015": [10, 11, 12, 14, 15, 16, 17, 18, 888, 994], "200016": [10, 11, 12, 14, 15, 16, 17, 18, 888, 961, 970, 988, 996], "200017": [10, 11, 12, 14, 15, 16, 17, 18, 888, 962, 982, 995], "200018": [9, 10, 11, 12, 14, 15, 16, 17, 18, 888, 962, 994], "200019": [9, 10, 11, 12, 14, 15, 16, 17, 18, 888, 972, 981, 986], "200020": [10, 11, 12, 14, 888, 967, 988, 994], "200021": [10, 11, 12, 14, 888, 954, 981, 985], "200022": [10, 11, 12, 14, 888, 991], "200023": [10, 11, 12, 14, 888, 955, 981], "200024": [10, 11, 12, 14, 888, 960, 976, 992], "200025": [10, 11, 12, 14, 888, 957, 982], "200026": [10, 11, 12, 14, 888, 973, 989], "200027": [10, 11, 12, 14, 888, 952, 968, 988], "200028": [10, 11, 12, 14, 888, 952, 971, 991], "200029": [10, 11, 12, 14, 888, 964, 976, 992], "200030": [10, 11, 12, 14, 888, 955, 979], "200031": [10, 11, 12, 14, 888, 959, 978], "200032": [10, 11, 12, 14, 888, 957, 976, 985], "200033": [10, 11, 12, 14, 888, 969], "200034": [10, 11, 12, 14, 969, 990], "200035": [10, 11, 12, 14, 969, 990], "200036": [10, 11, 12, 14, 969, 990], "200037": [10, 11, 12, 14, 969, 990], "200038": [10, 11, 12, 14, 888, 959, 967, 974], "200039": [10, 11, 12, 14, 888, 961, 970], "200040": [10, 11, 12, 14, 987], "200041": [10, 11, 12, 14, 987], "200042": [10, 11, 12, 14, 987], "200043": [10, 11, 12, 14, 987], "200044": [10, 11, 12, 14, 888, 960, 978], "200045": [10, 11, 12, 14, 888, 973, 981], "200046": [10, 11, 12, 14, 888, 967], "200047": [10, 11, 12, 14, 888, 957, 967], "200048": [10, 11, 12, 14, 888, 965, 971], "200049": [10, 11, 12, 14, 888, 954, 964], "200050": [10, 11, 12, 14, 980], "200051": [10, 11, 12, 14, 980], "200052": [10, 11, 12, 14, 888], "200053": [10, 11, 12, 14, 888, 958], "200054": [10, 11, 12, 14, 888, 953, 974], "200055": [10, 11, 12, 14, 975], "200056": [10, 11, 12, 14, 975], "200057": [10, 11, 12, 14, 975], "200058": [10, 11, 12, 14, 975], "200059": [10, 11, 12, 14, 888, 955, 960], "200060": [10, 11, 12, 14, 888, 958], "200061": [10, 11, 12, 14, 888], "200062": [10, 11, 12, 14, 969], "200063": [10, 11, 12, 14, 969], "200064": [10, 11, 12, 14, 969], "200065": [10, 11, 12, 14, 969], "200066": [10, 11, 12, 14, 888, 955, 962], "200067": [10, 11, 12, 14, 888, 954], "200068": [10, 11, 12, 14, 888, 955], "200069": [10, 11, 12, 14, 888, 953], "200070": [10, 11, 12, 14, 963], "200071": [10, 11, 12, 14, 963], "200072": [10, 11, 12, 14, 963], "200073": [10, 11, 12, 14, 963], "200074": [10, 11, 12, 14, 888], "200075": [10, 11, 12, 14, 888], "200076": [10, 11, 12, 14, 888], "200077": [10, 11, 12, 14, 888, 953], "200078": [10, 11, 12, 14, 888], "200079": [10, 11, 12, 956], "200080": [10, 11, 12, 956], "200081": [10, 11, 12, 956], "200082": [10, 11, 12, 956], "200083": [10, 11, 12, 888], "200084": [10, 11, 12, 888], "200085": [10, 11, 12, 888], "200086": [10, 11, 12, 952], "200087": [10, 11, 12, 952], "200088": [10, 11, 12, 952], "200089": [10, 11, 12, 952], "200090": [10, 11, 12, 888]}} \ No newline at end of file From 0e68849867adb11de2095c4f0fabbf5ac0547310 Mon Sep 17 00:00:00 2001 From: shinkuan Date: Thu, 2 May 2024 11:47:24 +0800 Subject: [PATCH 7/7] Catch error when getting logger. --- my_logger.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/my_logger.py b/my_logger.py index ca87895..de31cca 100644 --- a/my_logger.py +++ b/my_logger.py @@ -13,21 +13,25 @@ def my_sink(message: loguru.Message) -> None: record = message.record -logger.level("CLICK", no=10, icon="CLICK") -logger.add("akagi.log") -# logger.add(my_sink) - -RECORD_LOG_FIELDS = set((LogFields.record_name, LogFields.level)) -res = requests.get("https://fastly.jsdelivr.net/gh/shinkuan/RandomStuff/aliyun_log_handler_arg.json", allow_redirects=True) -json_data = json.loads(res.content) - -handler = QueuedLogHandler( - **json_data, - fields=RECORD_LOG_FIELDS, -) game_result_logger = logging.getLogger("game_result_log") game_result_logger.setLevel(logging.INFO) -game_result_logger.addHandler(handler) +try: + logger.level("CLICK", no=10, icon="CLICK") + logger.add("akagi.log") + # logger.add(my_sink) + + RECORD_LOG_FIELDS = set((LogFields.record_name, LogFields.level)) + res = requests.get("https://cdn.jsdelivr.net/gh/shinkuan/RandomStuff/aliyun_log_handler_arg.json", allow_redirects=True) + json_data = json.loads(res.content) + + handler = QueuedLogHandler( + **json_data, + fields=RECORD_LOG_FIELDS, + ) + + game_result_logger.addHandler(handler) +except Exception as e: + logger.error(f"Failed to set up log handler: {e}") def game_result_log(mode_id: int, rank: int, score: int, model_hash: str) -> None: if any((mode_id is None, rank is None, score is None, model_hash is None)):