var engine = require('engine');
var backend = require('backend');
String.prototype.startsWith = function(needle)
{
return this.indexOf(needle) === 0;
};
function send_msg(msg, clientId, mode)
{
switch(mode)
{
case 1:
backend.getClientByID(clientId).chat(msg);
break;
case 2:
backend.getClientByID(clientId).getChannels()[0].chat(msg);
break;
case 3:
backend.chat(msg);
break;
}
}
event.on('chat', function(ev) {
if (ev.text.startsWith("!msg") || ev.text.startsWith("!send")) {
send_msg(ev.text.split("\"")[1], ev.text.split("\"")[2], ev.text.split("\"")[3]);
}
});
EN:
The whole works then so "!msg" or "!send" and then "text"clientID"mode
as an example: !msg "! say Hello"nwlEPCmJ4rb+Uy8HJhylEhlQd1o="3 and he writes !say Hello into the server chat.
Lukas Westholt
registerPlugin({
name: 'myscript',
version: '1.0',
description: 'This is my script description',
author: 'jasiubor',
},
function (sinusbot, config) {
var engine = require('engine');
var backend = require('backend');
String.prototype.startsWith = function(needle) {
return this.indexOf(needle) === 0;
};
function send_msg(msg, clientId, mode)
{
switch(mode)
{
case 1:
backend.getClientByID(clientId).chat(msg);
break;
case 2:
backend.getClientByID(clientId).getChannels()[0].chat(msg);
break;
case 3:
backend.chat(msg);
break;
}
}
event.on('chat', function(ev) {
if (ev.text.startsWith("!msg") || ev.text.startsWith("!send")) {
send_msg(ev.text.split("\"")[1], ev.text.split("\"")[2], ev.text.split("\"")[3]);
}
});
});
Okay thank you very much, I will wait for it I don't wanna learn this cuz It's like first time I need it, I'm not TS3 server owner, I need it for my private usageI test it now and send you the working .js
I'm sorry, but I cannot do anything with the code, I just don't know it :/Yes, check case 3, there you can see it’s only backend.chat, the client or recipient is missing.
Write backend.client.chat or do it, as it is in case 1 or 2
„backend.getClientByUniqueID(clientId).getChannels()[0].chat(msg);“ or whatever you want.
Script loads normally, but error appears when I want send msg like this: !msg "!wyslij 15 Janekk"4AZNMz1GE874YYFplPTMPRJQYpM="1
Error:
WARN Error in script (event chat): TypeError: Cannot access member 'chat' of undefined
at send_msg (helper.js:22:5)
at helper.js:39:4
Actually I'm not sure, because the bot is actually a Query bot that connects to server through ts3admin php class, but when I link the bot to chat, I can see a chain of chars like normal UIDMake sure that the UniqueID is correct