├── .gitignore ├── public └── scripts │ ├── channelnamechanger.js │ ├── song_command.js │ ├── pause.js │ ├── announcetrack.js │ ├── freezer.js │ ├── norecording.js │ ├── badchan.js │ ├── greetonjoin.js │ ├── teammeeting.js │ ├── keywordmessage.js │ ├── badusername.js │ ├── idlemover.js │ ├── idle.js │ └── advertising.js ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | nbproject/ -------------------------------------------------------------------------------- /public/scripts/channelnamechanger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Raphael Touet 21 | * 22 | */ 23 | 24 | /* 25 | * 26 | * THIS SCRIPT IS IN DEVELOPMENT 27 | * 28 | */ 29 | -------------------------------------------------------------------------------- /public/scripts/song_command.js: -------------------------------------------------------------------------------- 1 | registerPlugin({ 2 | name: '!Song command', 3 | version: '1.0', 4 | description: 'Type !song to display the current track.', 5 | author: 'Raphael Touet ', 6 | vars: { 7 | message: { 8 | title: 'The message which is displayed', 9 | type: 'string', 10 | placeholder: 'Currently playing: %t by %a' 11 | } 12 | } 13 | }, function(sinusbot, config, info) { 14 | 15 | // as of included in the SinusBot v0.9.9-a4f6453 , the 'info' variable provides information about the script 16 | if(typeof info != 'undefined') { 17 | log(''); 18 | log('Loading...'); 19 | log(''); 20 | var author = info.author.split(','); 21 | if(author.length == 1){ 22 | author = author[0]; 23 | author = author.replace(/<.*>/gi, '').trim(); 24 | } else { 25 | author = author.map(function(e){ 26 | return e.replace(/<.*>/gi, '').trim(); 27 | }); 28 | author = author.join(' & '); 29 | } 30 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-50e8ba1 (and above)'); 31 | } 32 | 33 | if(typeof config.message == "undefined") {log('You have to define a message in the web-configuration of the script !'); return;} 34 | 35 | var cmd, track, msg; 36 | sinusbot.on('chat', function(ev) { 37 | if (ev.clientId == getBotId()) return; 38 | if (ev.mode == 3 || ev.mode == 2) return; 39 | cmd = ev.msg.trim().split(' '); 40 | cmd = cmd[0]; 41 | if(cmd != "!song") return; 42 | track = getTrack(); 43 | if(typeof track.artist != "undefined" && typeof track.title != "undefined") { 44 | msg = config.message.replace('%a', track.artist).replace('%t', track.title); 45 | } else { 46 | msg = config.message.replace('%t', track.filename); 47 | } 48 | chatPrivate(ev.clientId, msg); 49 | }); 50 | 51 | log('Loaded !'); 52 | log(''); 53 | }); -------------------------------------------------------------------------------- /public/scripts/pause.js: -------------------------------------------------------------------------------- 1 | registerPlugin({ 2 | name: 'Pause/Resume', 3 | version: '2.0', 4 | description: 'Type !pause to pause the current track, and type !resume to resume playback.', 5 | author: 'Bey0nd_Inf1nite, Raphael Touet ', 6 | vars: {} 7 | }, function(sinusbot, config, info) { 8 | 9 | // as of included in the SinusBot v0.9.9-a4f6453 , the 'info' variable provides information about the script 10 | if(typeof info != 'undefined') { 11 | log(''); 12 | log('Loading...'); 13 | log(''); 14 | var author = info.author.split(','); 15 | if(author.length == 1){ 16 | author = author[0]; 17 | author = author.replace(/<.*>/gi, '').trim(); 18 | } else { 19 | author = author.map(function(e){ 20 | return e.replace(/<.*>/gi, '').trim(); 21 | }); 22 | author = author.join(' & '); 23 | } 24 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-a4f6453 (and above)'); 25 | } 26 | 27 | var pos, track, accounts, account, priv_playback = 0x00001000, auth = false; // took out the variables 28 | sinusbot.on('chat', function(ev) { 29 | if (ev.mode == 3) return; // if the message is send in the server-chat, the bot will not response to avoid some communication errors with other bots 30 | accounts = getUsers(); 31 | for(var key in accounts) { 32 | account = accounts[key]; 33 | if(account.tsuid == ev.clientUid) { 34 | if(!(account.privileges & priv_playback)){ 35 | chatPrivate(ev.clientId, 'You don\'t have permission to do this!'); 36 | return; 37 | } 38 | auth = true; 39 | break; 40 | } 41 | } 42 | if(!auth) {chatPrivate(ev.clientId, 'You don\'t have permission to do this!'); return;} 43 | if (ev.msg.trim() == '!pause') { // add trim() : removes the whitespaces at the start and the end of the string. So '!pause ' or ' !pause ' will work to. 44 | track = getTrack(); 45 | if (!track) return; 46 | pos = getPos(); 47 | set(track.uuid, pos); 48 | chatChannel(ev.clientNick + ' paused the currently playing track.'); 49 | stop(); 50 | } 51 | if (ev.msg == '!resume') { 52 | play(track); 53 | var track = getTrack(); 54 | if (!track) return; 55 | var pos = get(track.uuid); 56 | if (!pos) { 57 | chatPrivate(ev.clientId, 'No track has been paused.'); 58 | return; 59 | } 60 | seek(pos); 61 | chatChannel(ev.clientNick + ' resumed the track'); 62 | } 63 | }); 64 | }); -------------------------------------------------------------------------------- /public/scripts/announcetrack.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Raphael Touet 21 | * 22 | */ 23 | 24 | registerPlugin({ 25 | name: 'Announce Track', 26 | version: '1.0', 27 | description: 'This script will announce (say) the specified message, each time a track is played. (Help: https://github.com/Raphouphe/sinusbot-scripts )', 28 | author: 'Raphael Touet ', 29 | vars: { 30 | message: { 31 | title: 'Announcing message', 32 | type: 'string', 33 | placeholder: 'Now playing: %t by %a' 34 | }, 35 | locale: { 36 | title: 'Locale', 37 | type: 'string', 38 | placeholder: 'en' 39 | } 40 | } 41 | }, function(sinusbot, config){ 42 | log("[Ann. Track] Announce Tracks v1.0 by Raphael Touet"); 43 | 44 | var msg = config.message, message; 45 | var locale = config.locale; 46 | 47 | if(!config.message) {log('[Ann. Track] Message not defined.');return;} 48 | if(!config.locale) {log('[Ann. Track] No locale defined. Using \'en\' !');locale = 'en';} 49 | 50 | if(!locale.match(/^utf-8$|^[a-z]{2}(?:-[a-z]{2})?$/i)) {log('[Ann. Track] Invalid locale.');return;} 51 | 52 | sinusbot.on('track', function (ev){ 53 | message = msg; 54 | message = message.replace(/%ala/gi,((typeof ev.albumArtist !== 'undefined' && ev.albumArtist !== '') ? ev.albumArtist : '')); 55 | if(typeof ev.tempArtist !== 'undefined' && ev.tempArtist !== '') message = message.replace(/%ta/gi,ev.tempArtist); 56 | if(typeof ev.tempTitle !== 'undefined' && ev.tempTitle !== '') message = message.replace(/%tt/gi,ev.tempTitle); 57 | message = message.replace(/%al/gi,((typeof ev.album !== 'undefined' && ev.album !== '') ? ev.album : '')); 58 | message = message.replace(/%a/gi,((typeof ev.artist !== 'undefined' && ev.artist !== '') ? ev.artist : '')) 59 | .replace(/%t/gi,((typeof ev.title !== 'undefined' && ev.title !== '') ? ev.title : '')) 60 | .replace(/%d/gi,((typeof ev.duration !== 'undefined' && ev.duration > 0) ? ev.duration : '')); 61 | say(message,locale); 62 | }); 63 | 64 | log('[Ann. Track] Initialized script.'); 65 | 66 | }); 67 | -------------------------------------------------------------------------------- /public/scripts/freezer.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Raphael Touet 21 | * 22 | */ 23 | 24 | registerPlugin({ 25 | name: 'Freezer', 26 | version: '1.0', 27 | description: 'This script will be able to freeze a user. (Help: https://github.com/Raphouphe/sinusbot-scripts)', 28 | author: 'Raphael Touet ', 29 | vars: { 30 | permissions: { 31 | title: 'Permission: ClientUIDs / ServergroupIDs', 32 | type: 'string', 33 | placeholder: 'JmVEkJ8Zt27E5ANPRFTTNwtqrl0= , 50' 34 | }, 35 | del_data: { 36 | title: 'Delete stored data', 37 | type: 'select', 38 | options: [ 39 | 'No', 40 | 'Yes' 41 | ] 42 | } 43 | } 44 | }, function(sinusbot, config, info) { 45 | // -- Load messages -- 46 | log(''); 47 | log('Loading...'); 48 | log(''); 49 | var author = info.author.split(','); 50 | if(author.length == 1){ 51 | author = author[0]; 52 | author = author.replace(/<.*>/gi, '').trim(); 53 | } else { 54 | author = author.map(function(e){ 55 | return e.replace(/<.*>/gi, '').trim(); 56 | }); 57 | author = author.join(' & '); 58 | } 59 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-??? (and above)'); 60 | 61 | var permissions = []; 62 | if (typeof config.permissions != "undefined") { 63 | permissions = config.permissions.split(",").map(function(e,i,a){ 64 | return e.trim(); 65 | }); 66 | } 67 | if (typeof config.del_data == "undefined") {config.del_data = 0;} 68 | else { 69 | if (config.del_data == 1) { 70 | unset('freezer_freezed'); 71 | config.del_data = 0; 72 | } 73 | } 74 | 75 | var freezed = get('freezer_freezed'); 76 | if (typeof freezed == "undefined") freezed = {}; 77 | 78 | var freeze = function(uid, until, channel_id) { 79 | freezed[uid] = {uid: uid, until: until, channel_id: channel_id}; 80 | set('freezer_freezed', freezed); 81 | }; 82 | 83 | var unfreeze = function() { 84 | 85 | }; 86 | 87 | // -- Information -- 88 | log('Loaded !'); 89 | log(''); 90 | }); -------------------------------------------------------------------------------- /public/scripts/norecording.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Michael Friese 21 | * @author Raphael Touet 22 | * 23 | */ 24 | registerPlugin({ 25 | name: 'No Recording!', 26 | version: '2.1', 27 | description: 'This script will kick anyone who attempts to record. (Help: https://github.com/Raphouphe/sinusbot-scripts)', 28 | author: 'Michael Friese , Raphael Touet ', 29 | vars: { 30 | kickMessage: { 31 | title: 'Used kick message', 32 | type: 'string', 33 | placeholder: 'No recording on our server!' 34 | }, 35 | exemptChannels: { 36 | title: 'Channel-names or ids (one per line)', 37 | type: 'multiline' 38 | }, 39 | whitelistOrBlacklist: { 40 | title: 'Either allowing recording in the specified channels or not', 41 | type: 'select', 42 | options: [ 43 | 'Allow', 44 | 'Deny' 45 | ] 46 | } 47 | } 48 | }, function(sinusbot, config, info) { 49 | // -- Load messages -- 50 | log(''); 51 | log('Loading...'); 52 | log(''); 53 | var author = info.author.split(','); 54 | if(author.length == 1){ 55 | author = author[0]; 56 | author = author.replace(/<.*>/gi, '').trim(); 57 | } else { 58 | author = author.map(function(e){ 59 | return e.replace(/<.*>/gi, '').trim(); 60 | }); 61 | author = author.join(' & '); 62 | } 63 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-a4f6453 (and above)'); 64 | 65 | if(typeof config.whitelistOrBlacklist == 'undefined') {config.whitelistOrBlacklist = 0} 66 | if(typeof config.exemptChannels == 'undefined') {config.exemptChannels = ""} 67 | 68 | var whitelistOrBlacklist = config.whitelistOrBlacklist; 69 | 70 | var exemptedChannelNames = config.exemptChannels.split('\n').map(function(e) { 71 | var ex = e.trim().replace(/\r/g, ''); 72 | if(parseInt(ex, 10)) { 73 | return parseInt(ex, 10); 74 | } 75 | return ex; 76 | }); 77 | var exemptChannels = []; 78 | 79 | sinusbot.on('record', function(ev) { 80 | var channels = getChannels(); 81 | var channel; 82 | for (var i = 0; i < channels.length; i++) { 83 | channel = channels[i]; 84 | if (exemptChannels.indexOf(channel.id) >= 0) { 85 | if (whitelistOrBlacklist == 0){ 86 | return; 87 | } 88 | } 89 | } 90 | kickServer(ev.clientId, config.kickMessage); 91 | log('Client with id: ' + ev.clientId + ' tried to record. Kicking...'); 92 | }); 93 | 94 | var updateChannels = function() { 95 | log('Connected, getting channels'); 96 | var channels = getChannels(), ex; 97 | var channel_names = channels.map(function(e) { return e.name }); 98 | for(var i = 0; i < exemptedChannelNames.length; i++){ 99 | ex = exemptedChannelNames[i]; 100 | if(typeof ex == 'number'){ 101 | exemptChannels.push(ex); 102 | continue; 103 | } 104 | if(channel_names.indexOf(ex) >= 0){ 105 | var id = channels[channel_names.indexOf(ex)].id; 106 | if(exemptChannels.indexOf(id) == -1){ 107 | exemptChannels.push(id); 108 | } 109 | } 110 | } 111 | log('Exempted channels: ' + exemptChannels.toString()); 112 | }; 113 | 114 | updateChannels(); 115 | sinusbot.on('connect', updateChannels); 116 | 117 | // -- Information -- 118 | log('Loaded !'); 119 | log(''); 120 | }); 121 | 122 | -------------------------------------------------------------------------------- /public/scripts/badchan.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Michael Friese 21 | * @author Raphael Touet 22 | * 23 | */ 24 | 25 | registerPlugin({ 26 | name: 'Bad Channel Names', 27 | version: '2.2', 28 | description: 'This script will remove all channels matching some userdefined names. (Help: https://github.com/Raphouphe/sinusbot-scripts)', 29 | author: 'Michael Friese , Raphael Touet ', 30 | vars: { 31 | names: { 32 | title: 'Forbidden channels (names)', 33 | type: 'multiline' 34 | }, 35 | ignoredChannels: { 36 | title: 'Ignored channels (ids)', 37 | type: 'string' 38 | } 39 | } 40 | }, function(sinusbot, config, info) { 41 | // -- Load messages -- 42 | log(''); 43 | log('Loading...'); 44 | log(''); 45 | var author = info.author.split(','); 46 | if(author.length == 1){ 47 | author = author[0]; 48 | author = author.replace(/<.*>/gi, '').trim(); 49 | } else { 50 | author = author.map(function(e){ 51 | return e.replace(/<.*>/gi, '').trim(); 52 | }); 53 | author = author.join(' & '); 54 | } 55 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-a4f6453 (and above)'); 56 | 57 | if (typeof config.names == 'undefined') {log('Invalid channel names'); return;} 58 | var ignoredChannels = []; 59 | if (typeof config.ignoredChannels != 'undefined'){ 60 | ignoredChannels = config.ignoredChannels.split('\n').map(function(e) { 61 | var n = parseInt(e.trim().replace(/\r/g, '')); 62 | if(!n){ 63 | return -1; 64 | } 65 | return n; 66 | }); 67 | } 68 | 69 | var names = config.names.split('\n').map(function(e) { return e.trim().replace(/\r/g, ''); }); 70 | 71 | var convertToRegex = function(string) { 72 | string = string.substr(1); 73 | var arr = string.split("/"); 74 | return new RegExp(arr[0],arr[1]); 75 | } 76 | 77 | sinusbot.on('channelCreate', function(ev) { 78 | if (!ev.name) return; // should not happen 79 | if (ignoredChannels.indexOf(ev.id) >= 0) return; 80 | var expression, reg; 81 | for (var i = 0; i < names.length; i++) { 82 | expression = names[i]; 83 | if (expression.match(/^\/.*\/.*$/)){ 84 | reg = convertToRegex(names[i]); 85 | if(ev.name.match(reg)){ 86 | log('Deleting channel ' + ev.name); 87 | channelDelete(ev.id, true); 88 | return; 89 | } 90 | } else { 91 | if (ev.name.toLowerCase().indexOf(expression.toLowerCase()) >= 0) { 92 | log('Deleting channel ' + ev.name); 93 | channelDelete(ev.id, true); 94 | return; 95 | } 96 | } 97 | } 98 | }); 99 | 100 | var updateChannels = function() { 101 | var channels = getChannels(); 102 | var removed = []; 103 | var channel; 104 | for(var j = 0; j < channels.length; j++){ 105 | channel = channels[j]; 106 | if (ignoredChannels.indexOf(channel.id) >= 0) continue; 107 | for (var i = 0; i < names.length; i++) { 108 | if (names[i].match(/^\/.*\/.*$/)){ 109 | var reg = convertToRegex(names[i]); 110 | if(channel.name.match(reg)){ 111 | removed.push(channel.name); 112 | channelDelete(channel.id, true); 113 | } 114 | } else { 115 | if (channel.name.toLowerCase().indexOf(names[i].toLowerCase()) >= 0) { 116 | removed.push(channel.name); 117 | channelDelete(channel.id, true); 118 | } 119 | } 120 | } 121 | } 122 | if(removed.length > 0) log('Removed following channels: ' + removed.toString()); 123 | }; 124 | 125 | updateChannels(); 126 | sinusbot.on('connect', updateChannels); 127 | 128 | // -- Information -- 129 | log('Loaded !'); 130 | log(''); 131 | 132 | }); 133 | 134 | -------------------------------------------------------------------------------- /public/scripts/greetonjoin.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Raphael Touet 21 | * 22 | */ 23 | registerPlugin({ 24 | name: 'Join-Greeting', 25 | version: '2.3', 26 | description: 'This script will let the bot greet everyone who joins the channel.', 27 | author: 'Raphael Touet ', 28 | vars: { 29 | message: { 30 | title: 'Message (%n = nickname)', 31 | type: 'string', 32 | placeholder: 'f.e. Welcome %n' 33 | }, 34 | type: { 35 | title: 'Message-Type', 36 | type: 'select', 37 | options: [ 38 | 'Private chat', 39 | 'Channel chat', 40 | 'Poke', 41 | 'Say' 42 | ] 43 | }, 44 | reformat_nick: { 45 | title: 'Reformat nickname', 46 | type: 'select', 47 | options: [ 48 | 'No', 49 | 'Yes' 50 | ] 51 | }, 52 | /*reformat_string: { 53 | title: 'Reformat nickname - format', 54 | type: 'string', 55 | placeholder: '/^.* | .*$/i' 56 | },*/ 57 | reformat_info: { 58 | title: 'Reformat nickname - details', 59 | type: 'multiline' 60 | // split: | 61 | // pos: 1 62 | } 63 | } 64 | }, function(sinusbot, config, info){ 65 | // -- Load messages -- 66 | log(''); 67 | log('Loading...'); 68 | log(''); 69 | var author = info.author.split(','); 70 | if(author.length == 1){ 71 | author = author[0]; 72 | author = author.replace(/<.*>/gi, '').trim(); 73 | } else { 74 | author = author.map(function(e){ 75 | return e.replace(/<.*>/gi, '').trim(); 76 | }); 77 | author = author.join(' & '); 78 | } 79 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-a4f6453 (and above)'); 80 | 81 | if (!String.prototype.startsWith) { 82 | String.prototype.startsWith = function(searchString, position) { 83 | position = position || 0; 84 | return this.indexOf(searchString, position) === position; 85 | }; 86 | } 87 | 88 | if(typeof config.message == 'undefined') {log('Invalid message');return;} 89 | if(typeof config.type == 'undefined') {log('Invalid type');return;} 90 | 91 | var rf_nick_pos, rf_sep; 92 | if(typeof config.reformat_nick == 'undefined') {config.reformat_nick = 0;} 93 | if(config.reformat_nick == 1) { 94 | // if(typeof config.reformat_string == 'undefined') {log('Please define a reformat format! Disabled reformating feature.'); config.reformat_nick = 0;} 95 | if (typeof config.reformat_info == 'undefined') {log('Please define some reformat details! Disabled reformating feature.'); config.reformat_nick = 0;} 96 | else { 97 | var v = config.reformat_info.split('\n').map(function(e) { 98 | return e.trim(); 99 | }); 100 | for (var i = 0; i < v.length; i++) { 101 | if (v[i].startsWith('split:')) { 102 | rf_sep = v[i].replace('split:', '').trim(); 103 | } else if (v[i].startsWith('pos:')) { 104 | rf_nick_pos = parseInt(v[i].replace('pos:', '').trim()); 105 | if (isNaN(rf_nick_pos)) { 106 | log('The reformat detail \'pos\' has to be a number! Disabled reformating feature.'); 107 | config.reformat_nick = 0; 108 | } 109 | } 110 | } 111 | } 112 | } 113 | 114 | var type = config.type; 115 | 116 | 117 | sinusbot.on('clientJoin', function(ev){ 118 | var msg = config.message; 119 | var nick = ev.clientNick; 120 | if (config.reformat_nick == 1) { 121 | if (nick.toLowerCase().indexOf(rf_sep.toLowerCase()) != -1) { 122 | var s = nick.split(rf_sep); 123 | if (s[rf_nick_pos] != 'undefined') { 124 | nick = s[rf_nick_pos]; 125 | } 126 | } 127 | } 128 | msg = msg.replace(/%n/g, nick); 129 | if(type == 3){ 130 | msg = msg.replace(/\[.\](.{0,})\[\/.\]/i, '$1'); 131 | msg = msg.replace(/<.>(.{0,})<\/.>/i, '$1'); 132 | } 133 | 134 | if(type == 0){ 135 | chatPrivate(ev.clientId, msg); 136 | } else if(type == 1){ 137 | log('channel'); 138 | chatChannel(msg); 139 | } else if(type == 2){ 140 | poke(ev.clientId, msg); 141 | } else if(type == 3){ 142 | say(msg); 143 | } 144 | 145 | }); 146 | 147 | // -- Information -- 148 | log('Loaded !'); 149 | log(''); 150 | }); 151 | -------------------------------------------------------------------------------- /public/scripts/teammeeting.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Raphael Touet 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | /* 19 | * 20 | * @author Raphael Touet 21 | * 22 | */ 23 | 24 | registerPlugin({ 25 | name: 'Teammeeting', 26 | version: '1.0', 27 | description: 'This script will manage some teem-meetings.', 28 | author: 'Raphael Touet ', 29 | vars: { 30 | permissions: { 31 | title: 'Permission: ClientUIDs / ServergroupIDs', 32 | type: 'string', 33 | placeholder: 'JmVEkJ8Zt27E5ANPRFTTNwtqrl0= , 50' 34 | }, 35 | defaultName: { 36 | title: 'Default channel name', 37 | type: 'string', 38 | placeholder: '» Teambesprechung | %d %t' 39 | }, 40 | defaultTime: { 41 | title: 'Default time of the meeting', 42 | type: 'string', 43 | placeholder: '18h00' 44 | }, 45 | order: { 46 | title: 'Where to place the channel', 47 | type: 'string', 48 | placeholder: 'before: The Channel Name // after: the channel id' 49 | } 50 | } 51 | }, function(sinusbot, config, info) { 52 | // -- Load messages -- 53 | log(''); 54 | log('Loading...'); 55 | log(''); 56 | var author = info.author.split(','); 57 | if(author.length == 1){ 58 | author = author[0]; 59 | author = author.replace(/<.*>/gi, '').trim(); 60 | } else { 61 | author = author.map(function(e){ 62 | return e.replace(/<.*>/gi, '').trim(); 63 | }); 64 | author = author.join(' & '); 65 | } 66 | log(info.name + ' v' + info.version + ' by ' + author + ' for SinusBot v0.9.9-50e8ba1 (and above)'); 67 | 68 | // some basic variables 69 | var self = getBotId(), prefix = "["+info.name+"] "; 70 | 71 | // basic function 72 | var getChannel = function(ident) { 73 | var channels = getChannels(), channel; 74 | log(isNan(parseInt(ident))); 75 | if(isNan(parseInt(ident))===false){ 76 | ident = parseInt(ident); 77 | for(var i = 0; i= 0) ? config.order.order - 1 : 0; 106 | break; 107 | case "after": 108 | config.order = config.order.order + 1; 109 | break; 110 | default: 111 | log(prefix+"Please define where the channel have to be placed!"); 112 | return; 113 | } 114 | } 115 | 116 | // -- Recreating "startsWith()" function which isn't included in ECMAScript 5 -- 117 | if (!String.prototype.startsWith) { 118 | String.prototype.startsWith = function(searchString, position) { 119 | position = position || 0; 120 | return this.indexOf(searchString, position) === position; 121 | }; 122 | } 123 | 124 | // functions 125 | var mCreate = function(meetingDate, meetingTime){ 126 | meetingDate = typeof meetingDate !== 'undefined' ? meetingDate : (new Date()).getDate().toString() + "." + ((new Date()).getMonth() + 1).toString(); 127 | meetingTime = typeof meetingTime !== 'undefined' ? meetingTime : config.defaultTime; 128 | 129 | var name = config.defaultName.replace("%d",meetingDate).replace("%t",meetingTime); 130 | channelCreate({name: name, codec: 4, default: 0, enc: 1, maxClients: 0, parent: 0, perm: 1, pw: 0, quality: 10, sperm: 0, topic: "", order: config.order}); 131 | }; 132 | 133 | var command = []; 134 | sinusbot.on('chat', function(ev){ 135 | if(self == ev.clientId) return; 136 | if(ev.mode != 1) return; 137 | ev.msg = ev.msg.trim(); 138 | if(!ev.msg.startsWith('!')) return; 139 | command = ev.msg.substring(1).split(' ').map(function(e){return e.trim();}); 140 | if(command[0] != "meeting") return; 141 | switch(command[1]){ 142 | case "start": 143 | 144 | break; 145 | case "end": 146 | 147 | break; 148 | case "mute": 149 | 150 | break; 151 | case "create": 152 | if(command.length !== 4){ 153 | chatPrivate(ev.clientId, prefix+"Please retry: !meeting create