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

示例的lua代码在发出问句后报错 #73

Open
azwc opened this issue May 18, 2022 · 3 comments
Open

示例的lua代码在发出问句后报错 #73

azwc opened this issue May 18, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@azwc
Copy link

azwc commented May 18, 2022


org.luaj.vm2.LuaError: Event.subscribe("FriendMessageEvent", function(event)
    local reply = tostring(event.message):gsub("吗",""):gsub("?","!"):gsub("?","!")
    event.friend:sendMessage(Quote(msg) .. reply)
end)

-- 在mirai-console环境下可忽略下列代码
local bot = Bot(xx,"xx",{
        fileBasedDeviceInfo = "device.json"
})
bot:login():3 bad argument: userdata expected, got nil
        at org.luaj.vm2.LuaValue.argerror(LuaValue.java:1056)
        at org.luaj.vm2.LuaValue.checkuserdata(LuaValue.java:1008)
        at com.github.only52607.luakt.dsl.LuaValueExtensionsKt.getUserdataValue(LuaValueExtensions.kt:68)
        at com.github.only52607.luamirai.lua.mirai.message.MessageConstructorsTable$4.invoke(MessageConstructorsTable.kt:44)
        at com.github.only52607.luamirai.lua.mirai.message.MessageConstructorsTable$4.invoke(MessageConstructorsTable.kt:43)
        at com.github.only52607.luakt.dsl.LuaFunctionBuilderDslKt$oneArgLuaFunctionOf$1.call(LuaFunctionBuilderDsl.kt:30)
        at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:363)
        at org.luaj.vm2.LuaClosure.onInvoke(LuaClosure.java:178)
        at org.luaj.vm2.LuaClosure.invoke(LuaClosure.java:171)
        at com.github.only52607.luamirai.lua.mirai.event.EventTable$subscriberFunction$1$3.invokeSuspend(EventTable.kt:44)
        at com.github.only52607.luamirai.lua.mirai.event.EventTable$subscriberFunction$1$3.invoke(EventTable.kt)
        at com.github.only52607.luamirai.lua.mirai.event.EventTable$subscriberFunction$1$3.invoke(EventTable.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invokeSuspend(EventChannel.kt:432)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.event.EventChannel$subscribeAlways$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.event.EventChannel$filter$1$intercepted$thisIntercepted$1.invokeSuspend(EventChannel.kt:146)
        at net.mamoe.mirai.event.EventChannel$filter$1$intercepted$thisIntercepted$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.event.EventChannel$filter$1$intercepted$thisIntercepted$1.invoke(EventChannel.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invokeSuspend(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at net.mamoe.mirai.internal.event.Handler$onEvent$2.invoke(InternalEventListeners.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:166)
        at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
        at net.mamoe.mirai.internal.event.Handler.onEvent(InternalEventListeners.kt:50)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.process(InternalEventListeners.kt:166)
        at net.mamoe.mirai.internal.event.InternalEventListenersKt.callAndRemoveIfRequired(InternalEventListeners.kt:115)
        at net.mamoe.mirai.event._EventBroadcast.broadcastImpl(Event.kt:175)
        at net.mamoe.mirai.IMirai.broadcastEvent(IMirai.kt:318)
        at net.mamoe.mirai.internal.MiraiImpl.broadcastEvent$suspendImpl(MiraiImpl.kt:308)
        at net.mamoe.mirai.internal.MiraiImpl.broadcastEvent(MiraiImpl.kt)
        at net.mamoe.mirai.event._EventBroadcast.broadcastPublic$suspendImpl(Event.kt:162)
        at net.mamoe.mirai.event._EventBroadcast.broadcastPublic(Event.kt)
        at net.mamoe.mirai.event.EventKt.broadcast(Event.kt:147)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invokeSuspend(EventDispatcher.kt:90)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invoke(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcast$2.invoke(EventDispatcher.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:166)
        at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcast$suspendImpl(EventDispatcher.kt:89)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcast(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invokeSuspend(EventDispatcher.kt:105)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invoke(EventDispatcher.kt)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl$broadcastAsync$job$1.invoke(EventDispatcher.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
        at net.mamoe.mirai.internal.network.components.EventDispatcherImpl.broadcastAsync-kKe4JaQ(EventDispatcher.kt:102)
        at net.mamoe.mirai.internal.network.components.EventDispatcher.broadcastAsync-kKe4JaQ$default(EventDispatcher.kt:35)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.impl(PacketHandler.kt:87)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.impl(PacketHandler.kt:80)
        at net.mamoe.mirai.internal.network.components.EventBroadcasterPacketHandler.handlePacket(PacketHandler.kt:73)
        at net.mamoe.mirai.internal.network.components.PacketHandlerChain.handlePacket(PacketHandler.kt:42)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invokeSuspend(NetworkHandlerSupport.kt:84)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invoke(NetworkHandlerSupport.kt)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport$collectReceived$3.invoke(NetworkHandlerSupport.kt)
        at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:55)
        at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:112)
        at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
        at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
        at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
        at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
        at net.mamoe.mirai.internal.network.handler.NetworkHandlerSupport.collectReceived$mirai_core(NetworkHandlerSupport.kt:82)
        at net.mamoe.mirai.internal.network.impl.netty.NettyNetworkHandler$PacketDecodePipeline$send$1.invokeSuspend(NettyNetworkHandler.kt:178)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run(Unknown Source)
2022-05-18 10:01:23 V/Bot 2228145613: 叶孤城(xx) -> 我吗?

@only52607
Copy link
Owner

只是在发送问号的时候报错吗

@azwc
Copy link
Author

azwc commented May 18, 2022

只是在发送问号的时候报错吗

Event.subscribe("FriendMessageEvent", function(event)
    local reply = tostring(event.message):gsub("吗",""):gsub("?","!"):gsub("?","!")
    event.friend:sendMessage(Quote(msg) .. reply)
end)

-- 在mirai-console环境下可忽略下列代码
local bot = Bot(xxx,"xxx",{
	fileBasedDeviceInfo = "device.json"
})
bot:login()

这是示例的代码, 刚刚又试了一下, 只要发消息就报错

@only52607 only52607 added the bug Something isn't working label May 18, 2022
@only52607
Copy link
Owner

示例有误,已更改为

Event.subscribe("FriendMessageEvent", function(event)
    local reply = tostring(event.message):gsub("吗",""):gsub("?","!"):gsub("?","!")
    event.friend:sendMessage(Quote(event.message) .. reply)
end)

@only52607 only52607 added documentation Improvements or additions to documentation and removed bug Something isn't working labels May 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants