alexemanuelol / rustplusplus

A NodeJS Discord Bot that uses the rustplus.js library to utilize the power of the Rust+ Companion App with additional Quality-of-Life features.
GNU General Public License v3.0
212 stars 100 forks source link

Bot only using "Settings" channel #228

Closed OverInfinity closed 1 year ago

OverInfinity commented 1 year ago

Since it's my first time posting I want to thank you for your hard work! It's been such a great experience for us and made our gameplay much more enjoyable.

As the title mentions, the bot only uses the settings channel. It can send messages to all channels. But when setting up the bot for the first time and it starts to create the channels, it creates all channels fine but only posts anything in "Settings" channel and rest of the channels are empty.

The problem is reproducable across ARM and x86. The result is the same when doing /reset discord. But what's interesting is that the bot does nothing when doing /reset information for example but in the console it says "INFO: Successfully reset Discord." This doesn't apply to settings channel.

Another thing I saw was when deleting 1 of the empty channels and then do "/reset discord". The bot spits out an error in console that the channel wasn't found or something similar. Which I think confirms the bot is aware of the empty channels it just doesn't DO anything.

Keep in mind, I've given the bot full administrator rights.

This started happening after I formatted the server and reinstalled the bot. The reason for formatting server was that it started sending messages in discord with HTML tags. Like Hey there</.color> and commands in game stopped working. When I didn't find out the reason for the weird messages I just formatted server but this resulted in what my issue is now.

Picture of one of the empty channels. image Only settings channel has content. image

OverInfinity commented 1 year ago

Never mind the issue is resolved. I'm just too focused on the fact that there's something wrong with how I reinstalled it that I totally forgot that I have to pair with server AFTER the fact the bot is on...

So yeah now the bot kind of works. But I'm back to square 1 as the issue before I reinstalled it has once again been reproduced. I've also found out that RustPlusBot had exactly the same issue at the same time. Issues at this time:

alexemanuelol commented 1 year ago

Hmm interesting, I haven't noticed the HTML tags... Perhaps it was a temporary thing for rust+ or discord (?). Can I close the report?

OverInfinity commented 1 year ago

Good evening!

I've managed to get the commands in game to work again by changing 1 thing in rustplusEvents/message.js


message.broadcast.teamMessage.message.message =
        message.broadcast.teamMessage.message.message.replace(/^<color.+?<\/color>/g, '');

This only replaces <color> tags. But in teamchat channel it also has <size> tags.

So when I changed the above code to include both color and size tags the bot in game commands started working.

Unfortunately it still shows the html tags in teamchat channel and now doesn't send messages when posting in that channel.

alexemanuelol commented 1 year ago

Oh that must be a server specific thing then. Would you mind paste:ing the complete message variable?

OverInfinity commented 1 year ago

Oh I didn't think about that! The bot is connected to Rustafied server.

This is the change I made: On /src/rustplusEvents/message.js on line 72 you have: message.broadcast.teamMessage.message.message = message.broadcast.teamMessage.message.message.replace(/^<color.+?<\/color>/g, '');

I changed it to: message.broadcast.teamMessage.message.message = message.broadcast.teamMessage.message.message.replace(/<\/?(color|size)[^>]*>/gi, '');

But this only fixes in-game commands and doesn't fix teamchat channel. This brakes the function of sending messages from within teamchat and still displays the HTML tags as seen in the picture below: image

alexemanuelol commented 1 year ago

By the looks of the picture you just sent, it is the author of the message that is formatted, not the message. So if you're keen on regex, look at the author parameter. But feel free to do a console.log(message) and paste the output here :)

OverInfinity commented 1 year ago

I'm very sorry for my poor english. So I might of misunderstood. Do you mean the console output from NPM? 0|npm | 2023-9-03 23:22:41 INFO: FCM-listener Host will start in 5 seconds for guildId: 3470655813****, steamId: 765611980****. 0|npm | 2023-9-03 23:22:43 347065581322895360 Rustafied.com - EU Medium CONNECTING: CONNECTING TO SERVER... 0|npm | 2023-9-03 23:22:43 347065581322895360 Rustafied.com - EU Medium CONNECTED: CONNECTED TO SERVER. 0|npm | 2023-9-03 23:22:43 347065581322895360 Rustafied.com - EU Medium CONNECTED: RUSTPLUS OPERATIONAL. 0|npm | 2023-9-03 23:27:54 347065581322895360 Rustafied.com - EU Medium INFO: hypocritical just went AFK. 0|npm | 2023-9-03 23:27:54 347065581322895360 Rustafied.com - EU Medium INFO: :COMBATUNIT just went AFK. 0|npm | 2023-9-03 23:27:54 347065581322895360 Rustafied.com - EU Medium INFO: AfterInfinity™ just went AFK. 0|npm | 2023-9-03 23:28:25 347065581322895360 Rustafied.com - EU Medium EVENT: Heavy Scientists got called to the Large Oil Rig at East of grid 22.

My apologies if I misunderstood!

When I type in game or when I type in the teamchat it does not show up in the console. But for some reason it did fix itself now when sending messages from teamchat! I have no idea how. Only thing now is author having HTML tags and it's fixed :)

OverInfinity commented 1 year ago

Ok I've fixed the bot!

What I did is also add in message.js:

    message.broadcast.teamMessage.message.name =
        message.broadcast.teamMessage.message.name.replace(/<\/?(color|size)[^>]*>/gi, '');

Now message and name has no HTML tags and commands work! :)

alexemanuelol commented 1 year ago

What I mean is before the regex operations you do, paste this line console.log(message)

OverInfinity commented 1 year ago

Aha! I think I found out! I'm not able to use console.log in ubuntu but I found the logs. There is not much because I've reinstalled everything not so long after I figured out how to fix it. I intentionally left the logs before and after fix so you can see the difference.

{"level":"info","message":"2023-9-03 23:55:41 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>awd</color></size>, User: <size=15><color=#55aaff>AfterInfinity™</color></size> (76561198043591300)"}
{"level":"info","message":"2023-9-03 23:55:54 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>!time</color></size>, User: <size=15><color=#55aaff>AfterInfinity™</color></size> (76561198043591300)"}
{"level":"info","message":"2023-9-03 23:55:55 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>[BOT] Current Rust time is 21:34 | Sunrise: 07:35 | Sunset: 20:03 | Day length: 1 hour</color></size>, User: <size=15><color=#55aaff>:COMBATUNIT>
{"level":"info","message":"2023-9-03 23:58:12 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>R++ | hypocritical just went AFK.</color></size>, User: <size=15><color=#55aaff>AfterInfinity™</color></size> (76561198043591300)"}
{"level":"info","message":"2023-9-03 23:58:12 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>R++ | AfterInfinity™ just went AFK.</color></size>, User: <size=15><color=#55aaff>AfterInfinity™</color></size> (76561198043591300)"}
{"level":"info","message":"2023-9-04 00:00:03 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>[BOT] The Cargo Ship is active @ Top Right</color></size>, User: <size=15><color=#55aaff>:COMBATUNIT</color></size> (76561197991295630)"}
{"level":"info","message":"2023-9-04 00:00:03 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: <size=15><color=#ffffff>R++ | Cargo Ship enters the map from North East.</color></size>, User: <size=15><color=#55aaff>AfterInfinity™</color></size> (76561198043591300)>
{"level":"info","message":"2023-9-04 00:06:56 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: awdawd, User: AfterInfinity™ (76561198043591300)"}
{"level":"info","message":"2023-9-04 00:14:09 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: awd, User: AfterInfinity™ (76561198043591300)"}
{"level":"info","message":"2023-9-04 00:14:42 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: [BOT] Current Rust time is 10:52 | Sunrise: 07:35 | Sunset: 20:03 | Day length: 1 hour, User: :COMBATUNIT (76561197991295630)"}
{"level":"info","message":"2023-9-04 00:16:14 | 347065581322895360 | Rustafied.com - EU Medium | INFO: Message: awd, User: AfterInfinity™ (76561198043591300)"}
alexemanuelol commented 1 year ago

Why can't you use console.log?

alexemanuelol commented 1 year ago

I got another guy from the discord that has the same problem as you, also Rustafied servers.

OverInfinity commented 1 year ago

Well, short answer is I'm kind of dumb and don't know how to do it. I've tried finding out how to do it but I can't make sense of it and I feel bad for asking. But if it's not hard to explain I can do it and post it here for you.

Oh wow! So it really is Rustafied that has changed something. That makes sense actually because they've just started sending "announcements" in chat with different color and size text. For example: Rustafied blah blah: <--- Red and white with big font To report a player blah blah do /report <--- White text with small font

alexemanuelol commented 1 year ago

image

Just paste console.log(message) in the file rustplusplus/src/rustplusEvents/message.js

alexemanuelol commented 1 year ago

Fixed in: 0babbc42daa448d103d169e9b80dd09f87469eaa