Vice City: Multiplayer

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

Title: Discord Plugin
Post by: Luckshya on Mar 05, 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/sleepydiscord-squirrel/wiki/
Example code: Available on wiki

Source
Sleepy-Discord: https://github.com/yourWaifu/sleepy-discord
Plugin Source: https://github.com/Luckshya/sleepydiscord-squirrel

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/sleepydiscord-squirrel/releases

Linux
apt-get install libssl-dev
Binaries: https://github.com/Luckshya/sleepydiscord-squirrel/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 Mar 05, 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 Mar 05, 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 Mar 06, 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 Mar 07, 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 Mar 07, 2019, 11:55 PM
Quote from: Luckshya on Mar 06, 2019, 08:54 AMA 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 Mar 08, 2019, 02:46 AM
Quote from: Pau Grosso on Mar 07, 2019, 11:55 PMHow 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 Mar 08, 2019, 03:21 AM
Quote from: Luckshya on Mar 08, 2019, 02:46 AM
Quote from: Pau Grosso on Mar 07, 2019, 11:55 PMHow 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 Mar 09, 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 Mar 10, 2019, 10:56 AM
Sleepy-discord binaries are now available.
Title: Re: Discord Plugin
Post by: Luckshya on Mar 20, 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: D4rkR420R on Mar 20, 2019, 05:02 PM
Quote from: Luckshya on Mar 20, 2019, 05:53 AMA 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 Mar 26, 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 Mar 26, 2019, 02:10 PM
Quote from: Milos on Mar 26, 2019, 01:56 PMPlugin 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 Mar 26, 2019, 03:13 PM
I was using the wrong version, but I have another problem: in Linux, the plugin loads, but I have errors
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 **
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
[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 Mar 26, 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 Mar 30, 2019, 10:58 AM
Please make the plugin for 32bit version, my vps has 32bit linux
Title: Re: Discord Plugin
Post by: umar4911 on Mar 30, 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 Mar 31, 2019, 06:21 AM
Quote from: umar4911 on Mar 30, 2019, 05:18 PMJSON 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 Mar 31, 2019, 06:30 AM
Quote from: dracc on Mar 31, 2019, 06:21 AM
Quote from: umar4911 on Mar 30, 2019, 05:18 PMJSON 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 Mar 31, 2019, 06:41 AM
Quote from: umar4911 on Mar 31, 2019, 06:30 AM
Quote from: dracc on Mar 31, 2019, 06:21 AM
Quote from: umar4911 on Mar 30, 2019, 05:18 PMJSON 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 Apr 02, 2019, 12:44 PM
Quote from: dracc on Mar 31, 2019, 06:41 AM
Quote from: umar4911 on Mar 31, 2019, 06:30 AM
Quote from: dracc on Mar 31, 2019, 06:21 AM
Quote from: umar4911 on Mar 30, 2019, 05:18 PMJSON 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 Apr 08, 2019, 05:05 PM
Update v0.3.1

Download the latest Binaries from the repo release section!
Title: Re: Discord Plugin
Post by: umar4911 on Apr 08, 2019, 05:46 PM
Quote from: Luckshya on Apr 08, 2019, 05:05 PMUpdate 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 Apr 08, 2019, 06:01 PM
Quote from: umar4911 on Apr 08, 2019, 05:46 PMwhat 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 Apr 28, 2019, 08:24 AM
If any message has a Emoji in it, It sends empty line or \n to the server
Title: Re: Discord Plugin
Post by: Luckshya on May 10, 2020, 06:17 AM
Major Update!
The plugin has been updated to fix some important bugs and crashes.
Fixed random crashes.
Fixed an issue that would cause other parts of the script to throw unknown errors.
All other fixes/changes can be seen through the repository commits.

Repository has been changed and the old one has been dropped out: https://github.com/Luckshya/sleepydiscord-squirrel
Some notable changes are: content parameter is added to MessageEmbed (https://github.com/Luckshya/sleepydiscord-squirrel/wiki/Session_MessageEmbed)

Latest release can be found here: https://github.com/Luckshya/sleepydiscord-squirrel/releases

The plugin now automatically queue the messages incase it hits the rate limit.
The messages are now sent asynchronously.
Title: Re: Discord Plugin
Post by: Luckshya on May 15, 2020, 04:20 PM
Update v0.4.1 changelog :-

More about the new EditChannel here: https://github.com/Luckshya/sleepydiscord-squirrel/wiki/Session_EditChannel
Latest release: https://github.com/Luckshya/sleepydiscord-squirrel/releases
Title: Re: Discord Plugin
Post by: Luckshya on May 21, 2020, 03:28 PM
If anyone needs any other feature/function, let me know.
Title: Re: Discord Plugin
Post by: Luckshya on May 23, 2020, 04:19 PM
Update v0.4.2 changelog :-

More info about the new features added here: https://github.com/Luckshya/sleepydiscord-squirrel/wiki
Latest Release: https://github.com/Luckshya/sleepydiscord-squirrel/releases

Example code on wiki updated!
Title: Re: Discord Plugin
Post by: Luckshya on Jul 09, 2020, 03:10 PM
Update v0.4.4 changelog :-

Wiki has been restructured and newly added features have been added it. Make sure to see the wiki before using them.
Added example code for both internal cache enabled and disabled on wiki.

Wiki: https://github.com/Luckshya/sleepydiscord-squirrel/wiki
Release: https://github.com/Luckshya/sleepydiscord-squirrel/releases/

I recommend to keep the internal cache disabled and manage cache yourself. I have also provided an example script on wiki to cache data.

EDIT: New release has been deleted for some reason, will be available back soon.
EDIT #2: Releases have been re-uploaded, make sure you get the latest one again.
Title: Re: Discord Plugin
Post by: Anish87 on Jul 10, 2020, 09:13 AM
Nice! :)
Major update, really useful. Can you further explain the onDiscordUpdate though?
Title: Re: Discord Plugin
Post by: Razor. on Jul 10, 2020, 07:03 PM
I think it would be a type of event callback used in Discord. Try:
function onDiscordUpdate(connID, eventType, ...)
{
switch(eventType)
{
case SqDiscordEvent.Message:
print( "lol" );
break;
}
}
If i'm wrong, correct me.
Title: Re: Discord Plugin
Post by: Anish87 on Jul 24, 2020, 11:56 AM
Quote from: Razor. on Jul 10, 2020, 07:03 PMI think it would be a type of event callback used in Discord. Try:
function onDiscordUpdate(connID, eventType, ...)
{
switch(eventType)
{
case SqDiscordEvent.Message:
print( "lol" );
break;
}
}
If i'm wrong, correct me.

no you're not wrong. I got in touch with Luckshya after that reply and understood the thing.
Title: Re: Discord Plugin
Post by: Anish87 on Jul 30, 2020, 08:28 AM
I have a suggestion Luckshya... Please add the SetPresence parameter for the bot and AvatarURL for SqDiscord.User.
Title: Re: Discord Plugin
Post by: KrOoB_ on Aug 07, 2020, 10:54 PM
if we can move player to another channel on discord with this plugin, we are able to make a basic phone call system like moving player and other player (who is calling) to a private voice channel and they speak blah blah.
 am i right ?
Title: Re: Discord Plugin
Post by: DizzasTeR on Aug 08, 2020, 03:57 AM
Quote from: KrooB on Aug 07, 2020, 10:54 PMif we can move player to another channel on discord with this plugin, we are able to make a basic phone call system like moving player and other player (who is calling) to a private voice channel and they speak blah blah.
 am i right ?


Yes you can probably do that but they both have to be on discord of your server
Title: Re: Discord Plugin
Post by: KrOoB_ on Sep 30, 2020, 08:13 PM
how can i select/detect someone in voice channel ?
Title: Re: Discord Plugin
Post by: Hendrix on Jun 03, 2022, 12:58 PM
I'm having problems loading the plugin
Loaded plugin: xmlconf04rel64

Loaded plugin: sqlite04rel64

Loaded plugin: squirrel04rel64

Loaded plugin: hashing04rel64

Loaded plugin: geoip04rel64

Loaded plugin: sockets04rel64

Loaded plugin: announce04rel64

Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64

** Started VC:MP 0.4 Server **
 Port: 8192
 Max players: 100

[MODULE]  Loaded server.conf Loader for 0.4 by Stormeus
[MODULE]     >> Loaded server.conf for parsing
[MODULE]     >> Applied settings
[MODULE]     >> Loaded classes
[MODULE]     >> Loaded vehicles
[MODULE]     >> Loaded pickups
[MODULE]  Loaded server.conf successfully

[MODULE]  Loaded SQLite3 for VC:MP by Stormeus.

[MODULE]  Loaded SqVCMP 0.4 frontend by Stormeus. (v1.0)
[SCRIPT]  |------------------------------|
[SCRIPT]  | Server                       |
[SCRIPT]  | Made by Mack                 |
[SCRIPT]  |------------------------------|
[SCRIPT]  Vehiculos cargados: 0
[SCRIPT]  Config Loaded
[SCRIPT]  Total vehicles loaded: 221
[SCRIPT]  VEHICLES LOADED: 221
[SCRIPT]  [Loaded] Alias - 11242
[SCRIPT]  Pickups Loaded - 0
[SCRIPT]  Confirming echo bot details...
[SCRIPT]  Bot details confirmed!
[MODULE]  Loaded GeoIP for 0.4 by Crys.
            >> Loaded GeoIP.dat (GeoIP Country Edition)

[MODULE]  Loaded sq_sockets for VC:MP by the LU Dev Team (ported by Stormeus).
announcer: Ready to announce to masterlist(s)
[SCRIPT]  Attempting to set user, nick and mode....
[SCRIPT]  Task completed successfully.





and already install Win64OpenSSL_Light-3_0_3 and Win64OpenSSL-3_0_3 the full my operating system is x64
Title: Re: Discord Plugin
Post by: MRSK143 on Jun 04, 2022, 06:19 AM
Quote from: Hendrix on Jun 03, 2022, 12:58 PMI'm having problems loading the plugin
Loaded plugin: xmlconf04rel64

Loaded plugin: sqlite04rel64

Loaded plugin: squirrel04rel64

Loaded plugin: hashing04rel64

Loaded plugin: geoip04rel64

Loaded plugin: sockets04rel64

Loaded plugin: announce04rel64

Plugin error >> LoadLibrary() 'plugins/discord04rel64.dll' failed: Code 126
Failed to load plugin: discord04rel64

** Started VC:MP 0.4 Server **
 Port: 8192
 Max players: 100

[MODULE]  Loaded server.conf Loader for 0.4 by Stormeus
[MODULE]     >> Loaded server.conf for parsing
[MODULE]     >> Applied settings
[MODULE]     >> Loaded classes
[MODULE]     >> Loaded vehicles
[MODULE]     >> Loaded pickups
[MODULE]  Loaded server.conf successfully

[MODULE]  Loaded SQLite3 for VC:MP by Stormeus.

[MODULE]  Loaded SqVCMP 0.4 frontend by Stormeus. (v1.0)
[SCRIPT]  |------------------------------|
[SCRIPT]  | Server                       |
[SCRIPT]  | Made by Mack                 |
[SCRIPT]  |------------------------------|
[SCRIPT]  Vehiculos cargados: 0
[SCRIPT]  Config Loaded
[SCRIPT]  Total vehicles loaded: 221
[SCRIPT]  VEHICLES LOADED: 221
[SCRIPT]  [Loaded] Alias - 11242
[SCRIPT]  Pickups Loaded - 0
[SCRIPT]  Confirming echo bot details...
[SCRIPT]  Bot details confirmed!
[MODULE]  Loaded GeoIP for 0.4 by Crys.
            >> Loaded GeoIP.dat (GeoIP Country Edition)

[MODULE]  Loaded sq_sockets for VC:MP by the LU Dev Team (ported by Stormeus).
announcer: Ready to announce to masterlist(s)
[SCRIPT]  Attempting to set user, nick and mode....
[SCRIPT]  Task completed successfully.





and already install Win64OpenSSL_Light-3_0_3 and Win64OpenSSL-3_0_3 the full my operating system is x64
Hi bro, instead of 3_0_3 you should install 1_0_1 the old version because i faced that problem too
Title: Re: Discord Plugin
Post by: habi on Jun 18, 2022, 04:44 PM
QuoteHi bro, instead of 3_0_3 you should install 1_0_1 the old version because i faced that problem too
Saved my time.
Title: Re: Discord Plugin
Post by: Samir_HG on Aug 04, 2022, 05:13 PM
I'm having this problem when trying to connect:
[2022-08-04 21:56:45] [connect] Successful connection
[2022-08-04 21:56:45] [error] handle_transport_init received error: TLS handshake failed
[2022-08-04 21:56:45] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init)
disconnect
[2022-08-04 21:56:45] [connect] Successful connection
[2022-08-04 21:56:45] [error] handle_transport_init received error: TLS handshake failed
[2022-08-04 21:56:45] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init)
disconnect

Plugin versions used: x32 and x86
Systems used: Windows 10 Pro 21H2 and Ubuntu 20.04 (both updated)
OpenSSL downloaded from https://slproweb.com/products/Win32OpenSSL.html
Tried all versions available on the website.

On Linux, I downloaded libssl-dev as instructed in this tutorial.

I'm using the exact same script that worked months ago.
As a precaution, I decided to create a new one with only the most basic functions as suggested in more recent tutorials and also the examples on GitHub pages.

Two different ISPs were used in the connection attempt. In all the above scenarios returns the same error.
Title: Re: Discord Plugin
Post by: Emi on Aug 05, 2022, 12:19 PM
Quote from: Samir_HG on Aug 04, 2022, 05:13 PMI'm having this problem when trying to connect:
[2022-08-04 21:56:45] [connect] Successful connection
[2022-08-04 21:56:45] [error] handle_transport_init received error: TLS handshake failed
[2022-08-04 21:56:45] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init)
disconnect
[2022-08-04 21:56:45] [connect] Successful connection
[2022-08-04 21:56:45] [error] handle_transport_init received error: TLS handshake failed
[2022-08-04 21:56:45] [info] asio async_shutdown error: asio.ssl:336462231 (shutdown while in init)
disconnect

Plugin versions used: x32 and x86
Systems used: Windows 10 Pro 21H2 and Ubuntu 20.04 (both updated)
OpenSSL downloaded from https://slproweb.com/products/Win32OpenSSL.html
Tried all versions available on the website.

On Linux, I downloaded libssl-dev as instructed in this tutorial.

I'm using the exact same script that worked months ago.
As a precaution, I decided to create a new one with only the most basic functions as suggested in more recent tutorials and also the examples on GitHub pages.

Two different ISPs were used in the connection attempt. In all the above scenarios returns the same error.
Plugin doesn't work anymore, for nobody
Title: Re: Discord Plugin
Post by: Sebastian on Aug 16, 2022, 09:10 AM
Damn, was really wondering what happened to my server...
Title: Re: Discord Plugin
Post by: Samir_HG on Aug 18, 2022, 03:49 PM
Apparently it's a certificate issue.
Title: Re: Discord Plugin
Post by: gamingpro on Dec 07, 2023, 01:40 PM
when me open server32.exe console its showing me Handle_transport_init receivied error: TLS...