fjaros / wowchat

WoWChat is a clientless Discord integration chat bot for old versions of World of Warcraft.
GNU General Public License v3.0
139 stars 96 forks source link

?who and guildies online change to players online #77

Closed PentSec closed 2 years ago

PentSec commented 2 years ago

Hello again mate.

Can change these commands and how many onlines. but from the server and not from the guild?

?who = all players online. and "see 1 guildies online" change to all players online?

can it be changed without a lot of code?

thanks for you reply

fjaros commented 2 years ago

Not possible currently in the code, but the bot does support name match, ex "?who a" to get a list of names online containing "a" I guess it would be possible to do this server wide if you were to change in https://github.com/fjaros/wowchat/blob/master/src/main/scala/wowchat/game/GamePacketHandler.scala#L188 comment out the if statement and always send CMSG_WHO. and instead of arguments.get passing into buildWhoMessage, you would just pass in an empty string "" .

PentSec commented 2 years ago

i try it, maybe 5 hours. but dont work. i just delete if. and nothing :( my head is broken

override def handleWho(arguments: Option[String]): Option[String] = {
    val byteBuf = buildWhoMessage(arguments.get)
    ctx.get.writeAndFlush(Packet(CMSG_WHO, byteBuf))
}

i got this error.

[ERROR] /home/shell/wowchat/src/main/scala/wowchat/game/GamePacketHandler.scala:190: error: type mismatch;
[ERROR]  found   : io.netty.channel.ChannelFuture
[ERROR]  required: Option[String]
[ERROR]     ctx.get.writeAndFlush(Packet(CMSG_WHO, byteBuf))
[ERROR]                          ^
[ERROR] one error found
fjaros commented 2 years ago

well you just didn't read my comment. you deleted None and didn't replace arguments. get with ""

  override def handleWho(arguments: Option[String]): Option[String] = {
      val byteBuf = buildWhoMessage("")
      ctx.get.writeAndFlush(Packet(CMSG_WHO, byteBuf))
      None
  }
PentSec commented 2 years ago

im so sorry, now work. I tried so many things that my head became a vine.

now that it works buts it only gives me 3 matches and not all in /who. :thinking:

Edit: i found it here: https://github.com/fjaros/wowchat/blob/7ffc62e0fd343d570549b2f375b174778c23f541/src/main/scala/wowchat/game/GamePacketHandler.scala#L688

fjaros commented 2 years ago

yes you will need to remove .take(3) from this function https://github.com/fjaros/wowchat/blob/7ffc62e0fd343d570549b2f375b174778c23f541/src/main/scala/wowchat/game/GamePacketHandler.scala#L658

PentSec commented 2 years ago

yes. work perfectly. but in the first ?who dont work and terminal say that


 WARN  i.n.c.DefaultChannelPipeline - An exceptionCaught() event was fired, and it reached at the tail of the pipeline. It usually means the last handler in the pipeline did not handle the exception.
java.lang.NullPointerException: null
        at wowchat.game.GamePacketHandler.handle_SMSG_WHO(GamePacketHandler.scala:657)
        at wowchat.game.GamePacketHandler.channelParse(GamePacketHandler.scala:246)
        at wowchat.game.GamePacketHandlerTBC.channelParse(GamePacketHandlerTBC.scala:38)
        at wowchat.game.GamePacketHandler.channelRead(GamePacketHandler.scala:227)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
        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)

i need put "?who whatever" them work. normally with ?who

fjaros commented 2 years ago

since you changed the code, i don't know what line GamePacketHandler.scala:657 points to. but this means that whatever it was trying to use on that line was null. i am guessing likely the server didn't return any results perhaps? you should implement a try catch for this case.