• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

auto !sub & !unsub on join and leave channel

R3v07v3R

Active Member
I see the feature for the bots to be used in Subscribe mode and it works, but I'm wondering if it would be possible to make a script to !sub everyone who joins the bots channel and !unsub them if they leave.
Then users can sit in the channel to listen or they can roam around the server and still listen.

I am currently accomplishing this by using 2 bots in the same channel.
I send the link to both bots and people can decide if they want to use the channel or the whisper bot.


Extended Idea;
Could this be changed to use any channel to !sub and any another to !unsub? or 1 channel to do both depending on your current status?
 

Multivitamin

Well-Known Member
Tier III
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
you can test this one:

JavaScript:
registerPlugin({
  name: "Auto Sub/Unsub",
  version: "1.0.0",
  description: "enables subscription mode if a client connects to the bots channel and removes it when he disconnects",
  author: "Multivitamin <[email protected]>"
}, () => {
  const engine = require("engine")
  const backend = require("backend")
  const event = require("event")
  if (!engine.isSubscriptionMode()) return engine.log("Subscription Mode is not enabled! Will not load script!")
  event.on("clientMove", ({ fromChannel, toChannel, client }) => {
    const channel = backend.getBotClient().getAudioChannel()
    if (toChannel.equals(channel)) return client.setSubscription(true)
    if (fromChannel.equals(channel)) return client.setSubscription(false)
  })
})

just create a file with your name of choice in the scripts folder and paste the above content into it
if it does not work please send me your log so i can peek into it

Disclaimer: I did not test this
 
Last edited:

R3v07v3R

Active Member
I noticed a check in the script for Subscription Mode, so I turned Subscription mode off, joined and left the channel, turned Subscription mode on, joined and left the channel.

Here is the log;
2019/08/07 13:41:24 73b7cd32 0cff1ed2 INFO script auto_sub loaded
2019/08/07 13:41:24 73b7cd32 0cff1ed2 PLUGIN [ auto_sub:12:51] Subscription Mode is not enabled! Will not load script!
2019/08/07 13:41:24 73b7cd32 0cff1ed2 INFO script auto_sub loaded
 

Multivitamin

Well-Known Member
Tier III
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
modified the script, you can test again
 

R3v07v3R

Active Member
Here is the full log from reboot,through disabled Whisper mode and renabled

Code:
2019-08-07T22:36:21+02:00 [ command:36:20] No possible valid command found!
2019-08-07T22:36:21+02:00 [ OKlib:88:20] Registering as active Bot [63/H/CYcydD4VgSQjVwYoVHlb1C5mc=: DJ #01]
2019-08-07T22:36:21+02:00 New connection status 4; Error 0
2019-08-07T22:36:21+02:00 TS |INFO |PermManager | |Loading permissions from cache
2019-08-07T22:36:21+02:00 TS |INFO |ClientUI |1 |Connect status: Connection established
2019-08-07T22:36:21+02:00 New connection status 3; Error 0
2019-08-07T22:36:21+02:00 TS |INFO |ClientUI |1 |Connect status: Establishing connection
2019-08-07T22:36:20+02:00 TS |INFO | | |No image, refusing to display
2019-08-07T22:36:20+02:00 TS |INFO | | |No image, refusing to display
2019-08-07T22:36:20+02:00 New connection status 2; Error 0
2019-08-07T22:36:20+02:00 TS |INFO |ClientUI |1 |Connect status: Connected
2019-08-07T22:36:20+02:00 TS |DEVELOP |PktHandler | |Puzzle solve time: 3
2019-08-07T22:36:20+02:00 TS |INFO | | |Statistics report: Not yet, next report on Thu Aug 22 10:51:37 2019
2019-08-07T22:36:20+02:00 TS |INFO |ClientUI | |Last update check was: Sat Jan 1 00:00:01 2022
2019-08-07T22:36:20+02:00 TS |INFO |Bookmarks | |Collecting autoconnect bookmarks
2019-08-07T22:36:19+02:00 New connection status 1; Error 0
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI |1 |Connect status: Connecting
2019-08-07T22:36:19+02:00 TS |INFO |PreProSpeex |1 |Speex version: 1.2rc1
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI |1 |Initiating connection: 41.185.28.215:9988
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI |1 |Connect to server: 41.185.28.215
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI | |ts3server: 41.185.28.215?port=9988&nickname=DJ%20%2301&password=&cid=9355&channelpassword=
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI | |Using configuration location: /opt/sinusbot/data/ts3/73b7cd32-7971-405b-9c0d-30f7389485a5/0cff1ed2-b2bc-132c-e227-bcb1279d26c2/settings.db
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI | |Qt version: 5.12.1
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI | |Failed to init text to speech engine
2019-08-07T22:36:19+02:00 TS |DEVELOP |ClientUI | |Notifications init: Soundpack path: /opt/sinusbot/teamspeak3-client/sound/nosounds
2019-08-07T22:36:19+02:00 TS |INFO | | |*** Time [INIT]: 149
2019-08-07T22:36:19+02:00 TS |INFO | | |*** Time [MAINWINDOW]: 148
2019-08-07T22:36:19+02:00 TS |INFO |Plugins | |Loading plugin: libsoundbot_plugin.so
2019-08-07T22:36:19+02:00 TS |INFO | | |successfully downloaded revocation list for myteamspeak id
2019-08-07T22:36:19+02:00 TS |INFO | | |successfully downloaded revocation list for accounting
2019-08-07T22:36:19+02:00 TS |INFO |Addons | |Checking for addon updates...
2019-08-07T22:36:19+02:00 TS |ERROR |RevocationListCache| |Failed to import revocation list from cache
2019-08-07T22:36:19+02:00 TS |INFO |ClientUI | |Unable to create an Open GL context.
2019-08-07T22:36:19+02:00 TS |ERROR |SoundBckndIntf| |libpulse.so.0: cannot open shared object file: No such file or directory
2019-08-07T22:36:19+02:00 TS |INFO | | |Using hardware aes
2019-08-07T22:36:19+02:00 TS |INFO | | |SystemInformation: Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1+deb9u4 (2019-07-19) x86_64 Binary: 64bit
2019-08-07T22:36:19+02:00 TS |INFO | | |TeamSpeak 3 Client 3.3.0 (2019-06-18 09:29:01)
2019-08-07T22:36:18+02:00 Starting instance ts3server://41.185.28.215?port=9988&nickname=DJ%20%2301&password=&cid=9355&channelpassword=
2019-08-07T22:36:18+02:00 Could not create Notifications-Tabletable Notifications already exists
2019-08-07T22:36:18+02:00 Could not create WhisperReceive-Tabletable WhisperReceive already exists
2019-08-07T22:36:18+02:00 Could not create Chat-Tabletable Chat already exists
2019-08-07T22:36:15+02:00 TSClient quit.
2019-08-07T22:36:15+02:00 KILL [admin] OK
2019-08-07T22:36:14+02:00 New connection status 0; Error 0
2019-08-07T22:36:14+02:00 TS |INFO |ClientUI |1 |Disconnected or forced to leave, want autoreconnect = 0
2019-08-07T22:36:14+02:00 TS |INFO |ClientUI |1 |Connect status: Disconnected
2019-08-07T22:35:52+02:00 [ command:36:20] Will not handle messages from myself
2019-08-07T22:35:52+02:00 PRIVATE-CHAT [R3v07v3R] unsub
2019-08-07T22:35:36+02:00 BOT-CONFIG [admin] CHANPW CHAN ANNOUNCE DESCRIPTION ANNOUNCESTR TTSURL CC MODE OK
2019-08-07T22:35:17+02:00 [ NowPlaying:106:16] Found Car Music Mix 2019
2019-08-07T22:35:17+02:00 [ NowPlaying:126:20] Was too long, now truncated to: [cspacer0]♫ %trackInfo ♫
2019-08-07T22:35:17+02:00 [ NowPlaying:106:16] Found Best Remixes Of EDM Party Dance Electro House
2019-08-07T22:35:17+02:00 [ NowPlaying:160:16] Received new track event for Car Music Mix 2019 - Best Remixes Of EDM Party Dance Electro House by Car Bass Music
2019-08-07T22:35:17+02:00 PLAY [admin] 90a67cfd-f3b2-4f05-9d65-b5a1ae2b785e OK
2019-08-07T22:35:12+02:00 script auto_sub loaded
2019-08-07T22:35:12+02:00 [ auto_sub:12:51] Subscription Mode is not enabled! Will not load script!
2019-08-07T22:35:12+02:00 script NowPlaying loaded
2019-08-07T22:35:12+02:00 script command loaded
2019-08-07T22:35:12+02:00 [ command:36:20] registering command 'man'
2019-08-07T22:35:12+02:00 [ command:36:20] registering command 'help'
2019-08-07T22:35:12+02:00 [ command:36:20] command prefix is "!"
2019-08-07T22:35:12+02:00 script OKlib loaded
2019-08-07T22:35:12+02:00 [ OKlib:88:20] Registering as active Bot [34/H/CYcydD4VgSQjVwYoVHlb1C5mc=: DJ #01]
2019-08-07T22:35:12+02:00 unloading instance
2019-08-07T22:34:59+02:00 [ command:36:20] Will not handle messages from myself
2019-08-07T22:34:59+02:00 PRIVATE-CHAT [R3v07v3R] sub
2019-08-07T22:33:57+02:00 [ command:36:20] No possible valid command found!
2019-08-07T22:33:57+02:00 [ OKlib:88:20] Registering as active Bot [34/H/CYcydD4VgSQjVwYoVHlb1C5mc=: DJ #01]
2019-08-07T22:33:57+02:00 New connection status 4; Error 0
2019-08-07T22:33:57+02:00 TS |INFO |PermManager | |Loading permissions from cache
2019-08-07T22:33:57+02:00 TS |INFO |ClientUI |1 |Connect status: Connection established
2019-08-07T22:33:56+02:00 New connection status 3; Error 0
2019-08-07T22:33:56+02:00 TS |INFO |ClientUI |1 |Connect status: Establishing connection
2019-08-07T22:33:56+02:00 TS |INFO | | |No image, refusing to display
2019-08-07T22:33:56+02:00 TS |INFO | | |No image, refusing to display
2019-08-07T22:33:56+02:00 New connection status 2; Error 0
2019-08-07T22:33:56+02:00 TS |INFO |ClientUI |1 |Connect status: Connected
2019-08-07T22:33:55+02:00 TS |DEVELOP |PktHandler | |Puzzle solve time: 4
2019-08-07T22:33:55+02:00 TS |INFO | | |Statistics report: Not yet, next report on Thu Aug 22 10:51:37 2019
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI | |Last update check was: Sat Jan 1 00:00:01 2022
2019-08-07T22:33:55+02:00 TS |INFO |Bookmarks | |Collecting autoconnect bookmarks
2019-08-07T22:33:55+02:00 New connection status 1; Error 0
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI |1 |Connect status: Connecting
2019-08-07T22:33:55+02:00 TS |INFO |PreProSpeex |1 |Speex version: 1.2rc1
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI |1 |Initiating connection: 41.185.28.215:9988
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI |1 |Connect to server: 41.185.28.215
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI | |ts3server: 41.185.28.215?port=9988&nickname=DJ%20%2301&password=&cid=9355&channelpassword=
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI | |Using configuration location: /opt/sinusbot/data/ts3/73b7cd32-7971-405b-9c0d-30f7389485a5/0cff1ed2-b2bc-132c-e227-bcb1279d26c2/settings.db
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI | |Qt version: 5.12.1
2019-08-07T22:33:55+02:00 TS |INFO |ClientUI | |Failed to init text to speech engine
2019-08-07T22:33:55+02:00 TS |DEVELOP |ClientUI | |Notifications init: Soundpack path: /opt/sinusbot/teamspeak3-client/sound/nosounds
2019-08-07T22:33:55+02:00 TS |INFO | | |*** Time [INIT]: 150
2019-08-07T22:33:55+02:00 TS |INFO | | |*** Time [MAINWINDOW]: 149
2019-08-07T22:33:54+02:00 TS |INFO |Plugins | |Loading plugin: libsoundbot_plugin.so
2019-08-07T22:33:54+02:00 TS |INFO | | |successfully downloaded revocation list for myteamspeak id
2019-08-07T22:33:54+02:00 TS |INFO | | |successfully downloaded revocation list for accounting
2019-08-07T22:33:54+02:00 TS |INFO |Addons | |Checking for addon updates...
2019-08-07T22:33:54+02:00 TS |ERROR |RevocationListCache| |Failed to import revocation list from cache
2019-08-07T22:33:54+02:00 TS |INFO |ClientUI | |Unable to create an Open GL context.
2019-08-07T22:33:54+02:00 TS |ERROR |SoundBckndIntf| |libpulse.so.0: cannot open shared object file: No such file or directory
 

Nogi

Active Member
Tier II
Tier I
Hi you have finished your Script ? is it possible to use your script to ?
Greetz
Nogi19
 

Himsel

Well-Known Member
Contributor
The script works if you change setSubscription to subscribe as shown below or did I misunderstand something? I also find the idea very useful.
The script does what was requested in the title. auto !sub & !unsub on join and leave channel

Thanks @Multivitamin

JavaScript:
registerPlugin({
  name: "Auto Sub/Unsub",
  version: "1.0.0",
  description: "Users subscribe to the bot automatically when they join the bots channel and unsubscribe when they leave",
  author: "Plopo has modified Multivitamins example"
}, () => {
  const engine = require("engine")
  const backend = require("backend")
  const event = require("event")
  if (!engine.isSubscriptionMode()) return engine.log("Subscription Mode is not enabled! Will not load script!")
  event.on("clientMove", ({ fromChannel, toChannel, client }) => {
    const channel = backend.getBotClient().getAudioChannel()
    if (toChannel) {
    if (toChannel.equals(channel)) return client.subscribe(true)
    }

    if (fromChannel) {
    if (fromChannel.equals(channel)) return client.subscribe(false)
    }
  })
})



Edit: I have noticed that an error message appears when a user joins or leaves the server. Therefore I have slightly changed it again.
 

Attachments

  • Auto_Sub_And_Unsub.js
    780 bytes · Views: 12
Last edited:
Top