Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用模型事件总线event为str时报错 #48

Open
dangerII opened this issue Jun 26, 2022 · 1 comment
Open

使用模型事件总线event为str时报错 #48

dangerII opened this issue Jun 26, 2022 · 1 comment

Comments

@dangerII
Copy link

Python3.7使用自定义模型事件总线时,执行emit报错;
当传入event为str类型时,会调用super()的emit函数,但此时产生问题为ModelEventBus本身并没有在初始化时调用super()的初始化,且没有提供event_chain_generator,导致ModelEventBus对象不存在event_chain_generator属性;

Traceback (most recent call last):
  File "sendmsgEventTest.py", line 143, in thread_listen
    await mbus.emit(event, msgs)
  File "/usr/local/lib/python3.7/dist-packages/mirai/models/bus.py", line 119, in emit
    return await super().emit(event, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mirai/bus.py", line 187, in emit
    for m_event in self.event_chain_generator(event):
AttributeError: 'ModelEventBus' object has no attribute 'event_chain_generator'
@Wybxc
Copy link
Collaborator

Wybxc commented Jun 26, 2022

ModelEventBus 在即将发布的 0.3 中会废弃,所以这个问题没有修复的必要了。

对旧版本来说,尽量避免这种用法。在新版本中,事件的层级关系将全部由继承表示,原有的按字符串分割的层级将不再可用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants