Giter Site home page Giter Site logo

majsoul_wrapper's People

Contributors

747929791 avatar juzai123 avatar masaiki avatar nicognaw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

majsoul_wrapper's Issues

报错KeyError: 'fetchLastPrivacy'

https://github.com/747929791/MajsoulAI 的AI运行majsoul_wrapper的时候会报KeyError: 'fetchLastPrivacy'

具体信息如下:

(venv) D:\MajsoulAI-master>python main.py
waiting to calibrate the browser location
  Number of good matches: 642
  Homography Matrix: [[ 6.48872443e-01 -1.81677678e-04  6.75356641e+02]
 [ 5.29145342e-04  6.48279953e-01  2.50010905e+02]
 [ 5.38194002e-07 -1.41332255e-07  1.00000000e+00]]
Similarity: 0.9973840146991272
create AI subprocess locally
starting up on 127.0.0.1 port 7479
waiting for the AI
AI connection:  <class 'socket.socket'> <socket.socket fd=1628, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 7479), raddr=('127.0.0.1', 60383)> ('127.0.0.1', 60383)
waiting for the game to start
Traceback (most recent call last):
  File "main.py", line 744, in <module>
    MainLoop(level=level)
  File "main.py", line 705, in MainLoop
    while not aiWrapper.isPlaying():
  File "main.py", line 107, in isPlaying
    result = liqiProto.parse(flow_msg)
  File "D:\MajsoulAI-master\majsoul_wrapper\liqi.py", line 84, in parse
    proto_domain = self.jsonProto['nested'][lq]['nested'][service]['methods'][rpc]
KeyError: 'fetchLastPrivacy'

liqi.py存在致命错误,雀魂的实时对局处理算法更新了

liqi.py里面第65~66行

B = base64.b64decode(dict_obj['data'])
action_proto_obj = getattr(pb, dict_obj['name']).FromString(B)

即获取对局信息,该部分即使使用最新的liqi.json解析也会报错:

google.protobuf.message.DecodeError: Wrong wire type in tag.

我的环境为

Python 3.9.7
mitmproxy 6.0.2
protobuf 3.14.0(该版本为mitmproxy==6.0.2所依赖的、自动安装的)
protoc 3.14.0

目前的雀魂版本为 https://game.maj-soul.net/1/v0.10.174.w/res/proto/liqi.json

新install的mitmproxy缺少某些addons.py中import的module

首当其冲的是in script addons.py: No module named 'mitmproxy.connections'
尝试用import mitmproxy.connection解决之(乐)
接着是in script addons.py: No module named 'mitmproxy.proxy.protocol'
尝试用
import mitmproxy.tls
import mitmproxy.proxy
import mitmproxy.flow
等解决之
然后重量级的来了in script addons.py: module 'mitmproxy.websocket' has no attribute 'WebSocketFlow'
这没办法了,只能待会儿install一个旧版本的mitmproxy看看情况

OSX系统不兼容问题

在liqi.py的第39行 OS X系统运行会报错

源代码:
open(os.path.join(os.path.dirname(file), 'proto\liqi.json'), 'r'))
修改后:
open(os.path.join(os.path.dirname(file), 'proto/liqi.json'), 'r'))

可正常运行

liqi.py无法正确的转义WS对局信息

即使成功的部署了所有环境,都会在这最后一步卡死:

Traceback (most recent call last):
File "main.py", line 744, in
MainLoop(level=level)
File "main.py", line 724, in MainLoop
aiWrapper.recvFromMajsoul()
File "main.py", line 124, in recvFromMajsoul
result = self.liqiProto.parse(flow_msg)
File "C:***\MajsoulAI-master\majsoul_wrapper\liqi.py", line 66, in parse
action_proto_obj = getattr(pb, dict_obj['name']).FromString(B)
google.protobuf.message.DecodeError: Error parsing message

*已使用3.10.0编译最新的liqi.json文件。

【小白求助】 在配置完成后,浏览器成功打开,但是无法连接网页

image

addon能成功打开chrome,其他的插件也都安装配置好了。
但是,如图所示,cmd提示“设备没有发挥作用”,并且“无法连接到accounts.google.com”。

经我检查,在挂个人代理的情况下,我能用简易的脚本打开网页accounts.google.com。
但是在此addon打开的窗口中,我不能连接网页。我猜测这和37247端口有关,但不是很确定。

所以,请问这样的情况该如何解决?谢谢了。

chrome_options参数问题

在Selenium的最新版本中,webdriver.Chrome()构造函数不再接受chrome_options参数,而是改为使用options参数。

需要修改以下代码行:
browser = webdriver.Chrome(chrome_options=chrome_options)

改为:
browser = webdriver.Chrome(options=chrome_options)

liqi.py出现致命错误

liqi.py 65-68:

B = base64.b64decode(dict_obj['data'])
action_proto_obj = getattr(pb, dict_obj['name']).FromString(B)
action_dict_obj = MessageToDict(action_proto_obj)
dict_obj['data'] = action_dict_obj

日志:
Wrong wire type in tag.
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\site-packages\google\protobuf\internal\decoder.py", line 972, in _DecodeUnknownField
raise _DecodeError('Wrong wire type in tag.')
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\site-packages\google\protobuf\internal\python_message.py", line 1178, in InternalParse
(data, new_pos) = decoder._DecodeUnknownField(
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\site-packages\google\protobuf\internal\python_message.py", line 1127, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\site-packages\google\protobuf\internal\python_message.py", line 794, in FromString
message.MergeFromString(s)
File "C:\Users\12772\Desktop\MajsoulAI-master\majsoul_wrapper\liqi.py", line 67, in parse
action_dict_obj = MessageToDict(action_proto_obj)
File "C:\Users\12772\Desktop\MajsoulAI-master\main.py", line 124, in recvFromMajsoul
result = self.liqiProto.parse(flow_msg)
File "C:\Users\12772\Desktop\MajsoulAI-master\main.py", line 724, in MainLoop
aiWrapper.recvFromMajsoul()
File "C:\Users\12772\Desktop\MajsoulAI-master\main.py", line 744, in
MainLoop(level=level)
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\12772\AppData\Local\Programs\Python\Python38\Lib\runpy.py", line 194, in _run_module_as_main (Current frame)
return _run_code(code, main_globals, None,
google.protobuf.message.DecodeError: Wrong wire type in tag.

将上述代码第二行getattr()添加默认值""可以略过第一次报错(ActionMJStart)
{'step': 0, 'name': 'ActionMJStart', 'data': ''}
但是进入新的回合后data的值不为空时无法解码
{'step': 1, 'name': 'ActionNewRound', 'data': 'H/b75PhO8hTmKQEaJGBZ/3ppU1JxThiqHgATnE8BSWXnJL9c/dm9mqNxpsi8i/XO/bINs8/LBwbIiNxQdufk+vInt9iIo5ITP14LTCqWW0wPmL/jGxfTVc9U7tudwMQk8L2oMdTv5atY3WbxUiBvRY5o3kKJYjc0VyufGCUihW4bWF7H'}

修改后删除上述代码后两行会报另一个错:Unexpected end-group tag.

已经更换为最新版(v0.10.194.w)的最新liqi.json并进行proto→py转义

因为使用的是edge,protobuf需要3.14.0
使用protoc版本为3.14.0 使用protobufjs版本为v7.2.1(当前最新版) py3.8

proto模块解码分析wire_type为7

关于protobuf版本的问题

在使用pip安装依赖的时候,如果先安装mitmproxy,再安装protobuf。

由于mitmproxy依赖于protobuf,会自动安装依赖版本的protobuf。但是mitmproxy依赖的protobuf版本号为3.11.3,并非最后版本(issue提交时为3.13.0)。若以此版本的protobuf运行项目,会给出以下报错信息:

module 'google.protobuf.descriptor' has no attribute '_internal_create_key'

此时使用pip更新protobuf,可以正常更新,但是pip给出警告信息:

mitmproxy 5.2 requires protobuf<3.12,>=3.6.0, but you'll have protobuf 3.13.0 which is incompatible.

(另注: 此信息其实是ERROR级的,但是是pip新特性,将在Oct.2020之后生效。所以此处仍然成功更新了)

更新后,代码可以正常运行。

python版本:3.7.2(非anaconda)
pip版本:20.2.3

可以提供一下requirements文件吗?

在运行mitmproxy时报错:ImportError: cannot import name 'soft_unicode' from 'markupsafe'
markupsafe:2.1.0中移除了soft_unicode
为了解决这个问题我尝试了几个其他版本的Jinja2,但是仍然有版本不兼容的问题。
希望能提供一下requirements.txt文件以供参考,谢谢!

liqi.json > liqi.proto 遇到问题

$npm install -g protobufjs
$pbjs -t proto3 liqi.json > liqi.proto
按照readme里的说明安装了nodejs,然后执行上述命令后报错,个人不了解js,求助
Snipaste_2023-08-08_18-08-54

请问如何将majsoul_wrapper作为PyPI第三方Package使用?

我是个小白,因为是用anaconda安装的python,所以很多包都是在conda的目录下,导致cmd运行时找不到包。所以我想试试您说的第二种方法:作为第三方package使用。
但是我查了一下相关教程,要么是用“python setup.py install”安装的,要么是用“pip install some_package.whl”的方式安装的,在您的包里我既没有找到setup.py也没找到以whl结尾的文件,请问我该如何操作呢?

`mitmdump -s addons.py` 命令报错

这个命令报错..

╰─❯ mitmdump -s addons.py

Traceback (most recent call last):
  File "/opt/homebrew/bin/mitmdump", line 8, in <module>
    sys.exit(mitmdump())
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/tools/_main.py", line 164, in mitmdump
    m = run(dump.DumpMaster, cmdline.mitmdump, args, extra)
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/tools/_main.py", line 71, in run
    opts = options.Options()
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/options.py", line 50, in __init__
    self.add_option(
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/optmanager.py", line 109, in add_option
    self._options[name] = _Option(name, typespec, default, help, choices)
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/optmanager.py", line 34, in __init__
    typecheck.check_option_type(name, default, typespec)
  File "/opt/homebrew/lib/python3.9/site-packages/mitmproxy/utils/typecheck.py", line 73, in check_option_type
    elif not isinstance(value, typeinfo):
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 720, in __instancecheck__
    return self.__subclasscheck__(type(obj))
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/typing.py", line 723, in __subclasscheck__
    raise TypeError("Subscripted generics cannot be used with"
TypeError: Subscripted generics cannot be used with class and instance checks```

丢失文件“websocket_frames.pkl” missing file "websocket_frames.pkl"

addons.py中:

if name=='main':
#回放websocket流量
replay_path=os.path.join(os.path.dirname(file), 'websocket_frames.pkl')
history_msg = pickle.load(open(replay_path, 'rb'))
activated_flows = ['fake_id']
messages_dict = {'fake_id':history_msg}
其中的websocket_frames.pkl文件丢失

In addons.py:

if name=='main':
#回放websocket流量
replay_path=os.path.join(os.path.dirname(file), 'websocket_frames.pkl')
history_msg = pickle.load(open(replay_path, 'rb'))
activated_flows = ['fake_id']
messages_dict = {'fake_id':history_msg}

websocket_frames.pkl missing

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.