Nambers / MiraiCP

c++ SDK of Mirai
https://eritque-arcus.tech/MiraiCP/
GNU Affero General Public License v3.0
177 stars 31 forks source link

希望能够增加mirai的消息链构造 #7

Closed ARKMIO closed 3 years ago

ARKMIO commented 3 years ago

现在要拼接一条带文字、图片、at的消息过于繁琐

Nambers commented 3 years ago

下个版本可以通过+和.plus构造 image image

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

ARKMIO commented 3 years ago

谢谢您的回复。 有一点我想弄清楚,延时事件的触发是信号量抓捕然后跳转到信号处理函数吗。

------------------ 原始邮件 ------------------ 发件人: "Eritque arcus"<notifications@github.com>; 发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com>; 抄送: "379173433"<379173433@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

下个版本可以通过+和.plus构造

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ARKMIO commented 3 years ago

上面消息没有打完。。。是不是意味着,我写的延时事件,必须是可重入的。

------------------ 原始邮件 ------------------ 发件人: "Eritque arcus"<notifications@github.com>; 发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com>; 抄送: "379173433"<379173433@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

下个版本可以通过+和.plus构造

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ARKMIO commented 3 years ago

因为我发现,如果在群聊消息里对公共资源加锁访问,同时在延时事件中加锁访问,必定会触发死锁。

------------------ 原始邮件 ------------------ 发件人: "Eritque arcus"<notifications@github.com>; 发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com>; 抄送: "379173433"<379173433@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

下个版本可以通过+和.plus构造

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Nambers commented 3 years ago

不需要应该 这个延时就是在kt部分运行一个延时执行函数然后再广播延时结束事件,然后我提供了个id参数,也就是说你可以通过在延时那传入不同的自定义id来然后在事件那接受id并区分要执行什么功能,目前这个延时是一次性的,后面可能会考虑加周期性执行或定时执行,从kt调用而不是cpp延时主要是为了省去多线程和缓存jvm对象的麻烦

------------------ Original ------------------ From: ARKMIO <notifications@github.com> Date: Fri,Mar 5,2021 5:17 PM To: Nambers/MiraiCP <MiraiCP@noreply.github.com> Cc: Eritque arcus <1930893235@qq.com>, Comment <comment@noreply.github.com> Subject: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

上面消息没有打完。。。是不是意味着,我写的延时事件,必须是可重入的。

------------------&nbsp;原始邮件&nbsp;------------------ 发件人: "Eritque arcus"<notifications@github.com&gt;; 发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com&gt;; 抄送: "379173433"<379173433@qq.com&gt;; "Author"<author@noreply.github.com&gt;; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

下个版本可以通过+和.plus构造

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

ARKMIO commented 3 years ago

谢谢您的解答。最后我想知道一点的是,每条消息都会触发一次消息事件,如果第一次没有处理完然后来了新的消息,那么会因此中断第一次消息的执行吗。如果都会执行完,那这两个一起执行的事件是在一个线程中处理的吗

------------------ 原始邮件 ------------------ 发件人: "Eritque arcus"<notifications@github.com>; 发送时间: 2021年3月5日(星期五) 下午5:27 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com>; 抄送: "379173433"<379173433@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

不需要应该 这个延时就是在kt部分运行一个延时执行函数然后再广播延时结束事件,然后我提供了个id参数,也就是说你可以通过在延时那传入不同的自定义id来然后在事件那接受id并区分要执行什么功能,目前这个延时是一次性的,后面可能会考虑加周期性执行或定时执行,从kt调用而不是cpp延时主要是为了省去多线程和缓存jvm对象的麻烦

------------------ Original ------------------ From: ARKMIO <notifications@github.com&gt; Date: Fri,Mar 5,2021 5:17 PM To: Nambers/MiraiCP <MiraiCP@noreply.github.com&gt; Cc: Eritque arcus <1930893235@qq.com&gt;, Comment <comment@noreply.github.com&gt; Subject: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

上面消息没有打完。。。是不是意味着,我写的延时事件,必须是可重入的。

------------------&amp;nbsp;原始邮件&amp;nbsp;------------------ 发件人: "Eritque arcus"<notifications@github.com&amp;gt;;
发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com&amp;gt;;
抄送: "379173433"<379173433@qq.com&amp;gt;; "Author"<author@noreply.github.com&amp;gt;;
主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7)

下个版本可以通过+和.plus构造

+和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Nambers commented 3 years ago

谢谢您的解答。最后我想知道一点的是,每条消息都会触发一次消息事件,如果第一次没有处理完然后来了新的消息,那么会因此中断第一次消息的执行吗。如果都会执行完,那这两个一起执行的事件是在一个线程中处理的吗 ------------------ 原始邮件 ------------------ 发件人: "Eritque arcus"<notifications@github.com>; 发送时间: 2021年3月5日(星期五) 下午5:27 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com>; 抄送: "379173433"<379173433@qq.com>; "Author"<author@noreply.github.com>; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7) 不需要应该 这个延时就是在kt部分运行一个延时执行函数然后再广播延时结束事件,然后我提供了个id参数,也就是说你可以通过在延时那传入不同的自定义id来然后在事件那接受id并区分要执行什么功能,目前这个延时是一次性的,后面可能会考虑加周期性执行或定时执行,从kt调用而不是cpp延时主要是为了省去多线程和缓存jvm对象的麻烦 ------------------ Original ------------------ From: ARKMIO <notifications@github.com&gt; Date: Fri,Mar 5,2021 5:17 PM To: Nambers/MiraiCP <MiraiCP@noreply.github.com&gt; Cc: Eritque arcus <1930893235@qq.com&gt;, Comment <comment@noreply.github.com&gt; Subject: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7) 上面消息没有打完。。。是不是意味着,我写的延时事件,必须是可重入的。 ------------------&amp;nbsp;原始邮件&amp;nbsp;------------------ 发件人: "Eritque arcus"<notifications@github.com&amp;gt;; 发送时间: 2021年3月5日(星期五) 下午5:07 收件人: "Nambers/MiraiCP"<MiraiCP@noreply.github.com&amp;gt;; 抄送: "379173433"<379173433@qq.com&amp;gt;; "Author"<author@noreply.github.com&amp;gt;; 主题: Re: [Nambers/MiraiCP] 希望能够增加mirai的消息链构造 (#7) 下个版本可以通过+和.plus构造 +和plus的参数为MiraiCodeable类型,即可以传入Image,string和LightApp类型 — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

我觉得应该是在一个线程里,然后基于kt里的协程来协调,因为在kt上游部分调用jni的时候应该不存在同时调用,调用的地方是在消息监听里,而消息监听在mirai是基于kt的协程协调如果没记错

Nambers commented 3 years ago

726f8cf99e6b5d728b22bbc6ccad9bdf9623a034,已添加