-
Notifications
You must be signed in to change notification settings - Fork 1
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
文档太少了,不会用呀 #5
Comments
群发消息的话,用readme里面那个示例就行 文档迟些补上 |
谢谢你这么快回复,readme那个只能对别人发得做出回应。其实我想弄早报机器人,定时执行一下脚本发信息到群里 |
那你需要使用apscheduler之类的定时框架来调用函数 |
就是我不知道怎么实现主动发消息,我的程序: from ela.app import Mirai
from ela.message.models import Image
from ela.component.group import Group,Permission
# 指定群
# 这个可能也有问题
PixARK_g = Group(id= xxxxxxxxxx ,name='。。',permission=Permission.Owner)
print(str(PixARK_g))
# :id=xxxxxxxxxx name='。。' permission=<Permission.Owner: 'OWNER'>
#README中收到群消息输出是
# print(str(ev.group))
# :id=xxxxxxxxx name='。。' permission=<Permission.Owner: 'OWNER'>
# print(type(ev.group))
# :<class 'ela.component.group.Group'>
# 实例化类,以便接下来使用
mirai_app = Mirai("http://xxx.xxx.xxx.xxx:8080/",
qq=xxxxxx, verify_key="xxxxxx")
# 我不知道主动发信息这个函数绑定到哪里
@mirai_app.run()
async def morningNews(app: Mirai):
await mirai_app.sendGroupMessage(PixARK_g, [Image(url="https://api.vvhan.com/api/60s")])
if __name__ == '__main__':
mirai_app.run()
# 然后并没有发出任何消息 |
首先,group是内部类,不需要实例化 其次,run是启动主循环用的,它会阻塞程序来完成请求 最后,你需要参考 |
抱歉,我太笨了😥 # test.py
from ela.app import Mirai
from ela.message.models import Image
mirai_app = Mirai("http://xxx.xxx.xxx.xxx:8080/",
qq=xxxxxx, verify_key="xxxxxx")
mirai_app.sendGroupMessage(qq群号, [Image(url="https://api.vvhan.com/api/60s")]) 输出为 RuntimeWarning: coroutine 'API.sendGroupMessage' was never awaited
mirai_app.sendGroupMessage(qq群号, [Image(url="https://api.vvhan.com/api/60s")])
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x000001E40E662310> 并且也发不出去消息。我还是不知道怎么主动发送消息,实在麻烦您了。我也不着急。我应该好好学学python了😥 |
你知道异步吗? 我觉得你需要学习一下异步的相关知识 |
怎么主动给qq群或好友发消息呀
The text was updated successfully, but these errors were encountered: