Here you are, with the connect notification and "both" poke & chat message type. (If you want to poke & chat only on connection, say it)
It should work xd
JavaScript:
registerPlugin({
name: 'Not In Group Poker',
version: '0.1',
backends: ['ts3'],
description: 'Poke / message clients, that aren\'t in a specified group, every X seconds',
author: 'DrWarpMan',
vars: [
{
name: 'notinGroupPoker_status',
title: 'Enabled?',
type: 'select',
options: [
"Yes",
"No"
]
},
{
name: 'notinGroupPoker_time',
title: 'Time (in seconds), how often will the bot poke / message the user - every X seconds',
type: 'number',
conditions: [
{ field: 'notinGroupPoker_status', value: 0 }
],
placeholder: 120
},
{
name: 'notinGroupPoker_message',
title: 'Poke / Chat Message',
type: 'string',
conditions: [
{ field: 'notinGroupPoker_status', value: 0 }
]
},
{
name: 'notinGroupPoker_messagetype',
title: 'Message Type',
type: 'select',
options: [
"Poke",
"Chat",
"Both (Poke and Chat)"
],
conditions: [
{ field: 'notinGroupPoker_status', value: 0 }
]
},
{
name: 'notinGroupPoker_groups',
title: 'Groups ID list (that if user is not in, he will get notified)',
type: 'array',
vars: [
{
title: 'Server Group ID',
name: 'group_id',
type: 'number'
}
],
conditions: [
{ field: 'notinGroupPoker_status', value: 0 }
]
}
]
}, function (sinusbot, config) {
var engine = require('engine');
var backend = require('backend');
var event = require('event');
var pTime;
var pGroups = [];
if(config.notinGroupPoker_status == 1) {
engine.log("Group Poker is disabled. Script won\'t start!");
return;
}
if(config.notinGroupPoker_groups == undefined) {
engine.log("Groups are not defined! Script won\'t work!");
return;
} else
{
for (var i = 0; i < config.notinGroupPoker_groups.length; i++) {
pGroups.push(config.notinGroupPoker_groups[i].group_id.toString());
}
}
if(config.notinGroupPoker_message == undefined) {
engine.log("Group Poker message is undefined, poke / chat message will be send without a text!");
config.notinGroupPoker_message = "";
}
if(config.notinGroupPoker_time == undefined) {
engine.log("Group Poker time is undefined, changing to default - 120.");
pTime = 120;
} else if(config.notinGroupPoker_time < 1)
{
engine.log("Group Poker time is lower than number one, changing to default - 120.");
pTime = 120;
} else if(config.notinGroupPoker_time > 0)
{
pTime = config.notinGroupPoker_time;
}
setInterval(function(){
if(backend.isConnected()) {
backend.getClients().forEach(function(user) {
checkGroups(user);
});
}
}, pTime * 1000);
function checkGroups(client)
{
var clientGroups = [];
client.getServerGroups().forEach(
function (group) {
clientGroups.push(group.id());
}
)
if(!ifArrContainsAnotherArr(pGroups, clientGroups))
{
var message = config.notinGroupPoker_message;
if(config.notinGroupPoker_messagetype == undefined || config.notinGroupPoker_messagetype == 0) {
client.poke(message);
} else if(config.notinGroupPoker_messagetype == 1)
client.chat(message);
else if(config.notinGroupPoker_messagetype == 2)
{
client.chat(message);
client.poke(message);
}
}
}
function ifArrContainsAnotherArr(fArr, sArr) {
return sArr.some(function (v) {
return fArr.indexOf(v) >= 0;
});
};
setTimeout(function(){
event.on('clientMove', function (ev) {
if(ev.fromChannel == null)
{
checkGroups(ev.client);
}
});
}, 5000);
});
It should work xd