Vice City: Multiplayer

Server Development => Community Plugins => Topic started by: Luckshya on March 5th, 2019, 05:38 AM

Title: Discord Plugin
Post by: Luckshya on March 5th, 2019, 05:38 AM
Introduction
After releasing a discord module for SqMod, I got certain requests to do it for official squirrel plugin as well. So, I have managed to write a multi-bot discord plugin for it.

The plugin only comes with sleepy-discord library.

Documentation
Wiki: https://github.com/Luckshya/Sq-DiscordPlugin2/wiki/
Example code: https://github.com/Luckshya/Sq-DiscordPlugin2/wiki/Example-Code

Source
Sleepy-Discord: https://github.com/yourWaifu/sleepy-discord
Plugin Source: https://github.com/Luckshya/Sq-DiscordPlugin2

Installation/Requirements

Windows
Install OpenSSL from here: https://slproweb.com/products/Win32OpenSSL.html
Don't change any options while installing openssl.

Binaries: https://github.com/Luckshya/Sq-DiscordPlugin2/releases

Linux
Code: [Select]
apt-get install libssl-dev

Binaries: https://github.com/Luckshya/Sq-DiscordPlugin2/releases
(32 bit not available for now)

Credits

NOTE: You need to take care of the Discord rate limit yourself.
Title: Re: Discord Plugin
Post by: Luckshya on March 5th, 2019, 11:45 AM
Added function Regex_Match to check for special character/symbols for discord. More details in the main post.
Title: Re: Discord Plugin
Post by: Milos on March 5th, 2019, 09:58 PM
Very good, thanks for that.
Doubt: any way to get the level of channel users?
Report: When the bot receives a private message it crashes the server.
Title: Re: Discord Plugin
Post by: Luckshya on March 6th, 2019, 08:54 AM
A new update 0.2 has been released that brings the following changes.

Make sure you update the binaries from the latest release on the repo.
Title: Re: Discord Plugin
Post by: Luckshya on March 7th, 2019, 04:25 PM
Update v0.2.1 changelog.

Example scripts have been updated.
Make sure you get the latest binaries from the latest release on the repo.
Title: Re: Discord Plugin
Post by: Milos on March 7th, 2019, 11:55 PM
Quote from Luckshya on March 6th, 08:54 AM
A new update 0.2 has been released that brings the following changes.
  • Fixed an issue that causes server to crash when a DM is received by the bot.
  • Added param authorID to the event onDiscord_Message as updated in the example code.

Make sure you update the binaries from the latest release on the repo.
How useful is the authorNick if author already does this?
It returns nothing
(https://i.postimg.cc/cCcfx0ZR/asasaas.png)
Title: Re: Discord Plugin
Post by: Luckshya on March 8th, 2019, 02:46 AM
Quote from Pau Grosso on March 7th, 11:55 PM
How useful is the authorNick if author already does this?
It returns nothing
The authorNick param returns empty string if a user doesn't have any nickname set on discord.
It also returns null if a DM is received.

So, does 'Sprunk' has his nickname set in the bot's discord server?
Title: Re: Discord Plugin
Post by: Milos on March 8th, 2019, 03:21 AM
Quote from Luckshya on March 8th, 02:46 AM
Quote from Pau Grosso on March 7th, 11:55 PM
How useful is the authorNick if author already does this?
It returns nothing
The authorNick param returns empty string if a user doesn't have any nickname set on discord.
It also returns null if a DM is received.

So, does 'Sprunk' has his nickname set in the bot's discord server?
Oh now I understand. and no, it has no nickname on server ;D
Thanks
Title: Re: Discord Plugin
Post by: Luckshya on March 9th, 2019, 11:43 AM
Update v0.2.2 changelog.

NOTE: libdiscord users should not send empty messages or the message like "" or "\n" or "msg\n" or the server will crash. Support for it may be released in the next version.
Valid message can be: "\nmessage" or "msg1\nmsg2"
Title: Re: Discord Plugin
Post by: Luckshya on March 10th, 2019, 10:56 AM
Sleepy-discord binaries are now available.
Title: Re: Discord Plugin
Post by: Luckshya on March 20th, 2019, 05:53 AM
A new update v0.3 has been released that changes a lot of structure and introduces classes to manage discord session.
Refer to the main post for the changes.

A major feature added in this update are Embeds.
Title: Re: Discord Plugin
Post by: DarkRaZoR^ on March 20th, 2019, 05:02 PM
Quote from Luckshya on March 20th, 05:53 AM
A new update v0.3 has been released that changes a lot of structure and introduces classes to manage discord session.
Refer to the main post for the changes.

A major feature added in this update are Embeds.
Yeah! :D
Title: Re: Discord Plugin
Post by: Milos on March 26th, 2019, 01:56 PM
Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64
Title: Re: Discord Plugin
Post by: Luckshya on March 26th, 2019, 02:10 PM
Quote from Milos on March 26th, 01:56 PM
Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64
Did you install OpenSSL? Check the main post for the link.
Title: Re: Discord Plugin
Post by: Milos on March 26th, 2019, 03:13 PM
I was using the wrong version, but I have another problem: in Linux, the plugin loads, but I have errors
Code: [Select]
v0.4, (c) 2007-2014 VC:MP Team
Loaded plugin: squirrel04rel64
Loaded plugin: announce04rel64
Loaded plugin: sqlite04rel64
Loaded plugin: sockets04rel64
Loaded plugin: discord04rel64
Loaded plugin: hash-linux64
Loaded plugin: json04rel64
Loaded plugin: geoip04rel64
** Started VC:MP 0.4 Server **
Code: [Select]
AN ERROR HAS OCCURED [the index 'SqDiscord' does not exist]
CALLSTACK
*FUNCTION [constructor()] scripts/Discord.nut line [11]
*FUNCTION [main()] scripts/Discord.nut line [140]
*FUNCTION [dofile()] NATIVE line [-1]
*FUNCTION [onScriptLoad()] scripts/main.nut line [255]
LOCALS
[this] INSTANCE
[myDiscord] NULL
[vargv] ARRAY
[this] TABLE
[this] TABLE
AN ERROR HAS OCCURED [the index 'SqDiscord' does not exist]
CALLSTACK
*FUNCTION [onScriptLoad()] scripts/main.nut line [255]
LOCALS
[this] TABLE

double load
Code: [Select]
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.
[MODULE] Loaded Discord Connector for VC:MP 0.4 by Luckshya.
Title: Re: Discord Plugin
Post by: Luckshya on March 26th, 2019, 03:38 PM
Im not sure about this, I've tested the linux plugin again and it seems to work fine on my system. Can you contact me on discord? (Luckshya#5109)
Title: Re: Discord Plugin
Post by: Mursaleen Qureshi on March 30th, 2019, 10:58 AM
Please make the plugin for 32bit version, my vps has 32bit linux
Title: Re: Discord Plugin
Post by: umar4911 on March 30th, 2019, 05:18 PM
JSON Parse Error: variable #0: "name" not found. Please look at call stack from your debugger for more details.
@Luckshya
Title: Re: Discord Plugin
Post by: dracc on March 31st, 2019, 07:21 AM
Quote from umar4911 on March 30th, 05:18 PM
JSON Parse Error: variable #0: "name" not found. Please look at call stack from your debugger for more details.
@Luckshya
Well, did you look at the call stack?
Title: Re: Discord Plugin
Post by: umar4911 on March 31st, 2019, 07:30 AM
Quote from dracc on March 31st, 07:21 AM
Quote from umar4911 on March 30th, 05:18 PM
JSON Parse Error: variable #0: "name" not found. Please look at call stack from your debugger for more details.
@Luckshya
Well, did you look at the call stack?
How to see call stack :P
Title: Re: Discord Plugin
Post by: dracc on March 31st, 2019, 07:41 AM
Quote from umar4911 on March 31st, 07:30 AM
Quote from dracc on March 31st, 07:21 AM
Quote from umar4911 on March 30th, 05:18 PM
JSON Parse Error: variable #0: "name" not found. Please look at call stack from your debugger for more details.
@Luckshya
Well, did you look at the call stack?
How to see call stack :P
Depends on your servers operating system but in general it entails you running a debugger, opening the vcmp server through the debugger and when an error is encountered commanding the debugger to output a callstack/backtrace.
Title: Re: Discord Plugin
Post by: umar4911 on April 2nd, 2019, 01:44 PM
Quote from dracc on March 31st, 07:41 AM
Quote from umar4911 on March 31st, 07:30 AM
Quote from dracc on March 31st, 07:21 AM
Quote from umar4911 on March 30th, 05:18 PM
JSON Parse Error: variable #0: "name" not found. Please look at call stack from your debugger for more details.
@Luckshya
Well, did you look at the call stack?
How to see call stack :P
Depends on your servers operating system but in general it entails you running a debugger, opening the vcmp server through the debugger and when an error is encountered commanding the debugger to output a callstack/backtrace.
after coordination with Luckshya, we got to know the error.
Title: Re: Discord Plugin
Post by: Luckshya on April 8th, 2019, 06:05 PM
Update v0.3.1

Download the latest Binaries from the repo release section!
Title: Re: Discord Plugin
Post by: umar4911 on April 8th, 2019, 06:46 PM
Quote from Luckshya on April 8th, 06:05 PM
Update v0.3.1
  • Updated sleepy discord library to fix JSON Parse error when an EmbedField is sent without name or value.

Download the latest Binaries from the repo release section!
what does it really do? I mean does it skip that message or it parses that field
Title: Re: Discord Plugin
Post by: Luckshya on April 8th, 2019, 07:01 PM
Quote from umar4911 on April 8th, 06:46 PM
what does it really do? I mean does it skip that message or it parses that field
It does not skip and accepts the EmbedField without the name and value and then parse it.
Title: Re: Discord Plugin
Post by: umar4911 on April 28th, 2019, 09:24 AM
If any message has a Emoji in it, It sends empty line or \n to the server