Skip to content

Commit

Permalink
Merge pull request #48 from shinkuan/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
shinkuan authored May 2, 2024
2 parents 0021070 + 0e68849 commit e141be6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 22 deletions.
4 changes: 3 additions & 1 deletion action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


5 changes: 4 additions & 1 deletion client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions mitm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 17 additions & 13 deletions my_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://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 = 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)):
Expand Down
2 changes: 1 addition & 1 deletion resver.json
Original file line number Diff line number Diff line change
@@ -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]}}
{"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]}}
6 changes: 3 additions & 3 deletions simple_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e141be6

Please sign in to comment.