Dateien nach "scripts" hochladen
This commit is contained in:
parent
c0e07269b7
commit
27ebfdfd31
|
@ -0,0 +1 @@
|
||||||
|
### Default attached scripts of the SinusBot which are ported to the v8 scripting engine
|
|
@ -0,0 +1,74 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'Advertising (Text)',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3'],
|
||||||
|
description: 'This script will announce one of the configured lines every x seconds.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: [{
|
||||||
|
name: 'ads',
|
||||||
|
title: 'Ads (supports bbcode)',
|
||||||
|
type: 'multiline',
|
||||||
|
placeholder: 'Welcome to the best TS3-Server!'
|
||||||
|
}, {
|
||||||
|
name: 'interval',
|
||||||
|
title: 'Interval (in seconds)',
|
||||||
|
type: 'number',
|
||||||
|
placeholder: '5',
|
||||||
|
default: 5
|
||||||
|
}, {
|
||||||
|
name: 'order',
|
||||||
|
title: 'Order',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
'line by line (default)',
|
||||||
|
'random'
|
||||||
|
],
|
||||||
|
default: '0'
|
||||||
|
}, {
|
||||||
|
name: 'type',
|
||||||
|
title: 'Broadcast-Type',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
'Channel',
|
||||||
|
'Server'
|
||||||
|
],
|
||||||
|
default: '0'
|
||||||
|
}]
|
||||||
|
}, (_, {ads, order, type, interval}) => {
|
||||||
|
const backend = require('backend')
|
||||||
|
const engine = require('engine')
|
||||||
|
|
||||||
|
ads = ads ? ads.split('\n').map(line => line.trim().replace(/\r/g, '')) : []
|
||||||
|
|
||||||
|
if (ads.length === 0) {
|
||||||
|
engine.log('There are no ads configured.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (interval <= 3) {
|
||||||
|
engine.log('The interval is too small, use a value bigger than 3 seconds.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const RANDOM = '1';
|
||||||
|
const SERVER = '1';
|
||||||
|
|
||||||
|
let index = -1
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
switch (order) {
|
||||||
|
case RANDOM:
|
||||||
|
index = Math.floor(Math.random() * ads.length)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
index = (++index % ads.length)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case SERVER:
|
||||||
|
backend.chat(ads[index])
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
backend.getCurrentChannel().chat(ads[index])
|
||||||
|
}
|
||||||
|
}, interval * 1000)
|
||||||
|
})
|
|
@ -0,0 +1,62 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'AloneMode',
|
||||||
|
version: '3.2.0',
|
||||||
|
backends: ['ts3', 'discord'],
|
||||||
|
description: 'This script will save CPU and bandwidth by stopping or muting the bot when nobody is listening anyways.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle, Fabian "fabm3n"
|
||||||
|
vars: [{
|
||||||
|
name: 'mode',
|
||||||
|
title: 'Mode',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
'mute only',
|
||||||
|
'stop playback'
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}, (_, {mode}) => {
|
||||||
|
const engine = require('engine')
|
||||||
|
const backend = require('backend')
|
||||||
|
const event = require('event')
|
||||||
|
const audio = require('audio')
|
||||||
|
const media = require('media')
|
||||||
|
|
||||||
|
const MUTE_ONLY = '0'
|
||||||
|
|
||||||
|
let isMuted = false
|
||||||
|
let lastPosition = 0
|
||||||
|
let lastTrack
|
||||||
|
|
||||||
|
audio.setMute(false)
|
||||||
|
|
||||||
|
event.on('clientMove', () => {
|
||||||
|
let currentChannel = backend.getCurrentChannel()
|
||||||
|
let clients = currentChannel ? currentChannel.getClientCount() : 0
|
||||||
|
|
||||||
|
if (clients > 1 && isMuted) {
|
||||||
|
isMuted = false
|
||||||
|
engine.log('Ending AloneMode...')
|
||||||
|
|
||||||
|
if (mode == MUTE_ONLY) {
|
||||||
|
audio.setMute(false)
|
||||||
|
} else {
|
||||||
|
if (lastTrack) {
|
||||||
|
lastTrack.play()
|
||||||
|
audio.seek(lastPosition)
|
||||||
|
engine.log(`Seeking to ${lastPosition} of track '${lastTrack.title()}'`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (clients <= 1 && audio.isPlaying() && isMuted == false) {
|
||||||
|
isMuted = true
|
||||||
|
engine.log('Starting AloneMode...')
|
||||||
|
|
||||||
|
if (mode == MUTE_ONLY) {
|
||||||
|
audio.setMute(true)
|
||||||
|
} else {
|
||||||
|
lastPosition = audio.getTrackPosition()
|
||||||
|
lastTrack = media.getCurrentTrack()
|
||||||
|
engine.log(`Position ${lastPosition} saved for track '${lastTrack.title()}'`)
|
||||||
|
media.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,51 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'Bookmarks!',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3', 'discord'],
|
||||||
|
description: 'Enter .bookmark to save the current position, enter .resume to seek to the bookmarked position.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: []
|
||||||
|
}, () => {
|
||||||
|
const store = require('store')
|
||||||
|
const media = require('media')
|
||||||
|
const audio = require('audio')
|
||||||
|
const event = require('event')
|
||||||
|
|
||||||
|
event.on('load', () => {
|
||||||
|
//try to load the library
|
||||||
|
const Command = require('command')
|
||||||
|
//check if the library has been loaded successfully
|
||||||
|
if (!Command) throw new Error('Command.js library not found! Please download Command.js and enable it to be able use this script!')
|
||||||
|
|
||||||
|
Command.createCommand('bookmark')
|
||||||
|
.help('saves the current position')
|
||||||
|
.manual('saves the current position')
|
||||||
|
.manual('can be resumed by the \'resume\' command. (Seeks to the bookmarked position of the track)')
|
||||||
|
.exec((client, args, reply) => {
|
||||||
|
const track = media.getCurrentTrack()
|
||||||
|
if (!track) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const pos = audio.getTrackPosition()
|
||||||
|
store.set(track.id(), pos)
|
||||||
|
reply(`Position saved for track '${track.title()}' at ${pos} ms`)
|
||||||
|
})
|
||||||
|
|
||||||
|
Command.createCommand('resume')
|
||||||
|
.help('resumes to the bookmarked position')
|
||||||
|
.manual('resumes to the bookmarked position (use bookmark command to set)')
|
||||||
|
.exec((client, args, reply) => {
|
||||||
|
const track = media.getCurrentTrack()
|
||||||
|
if (!track) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const pos = store.get(track.id())
|
||||||
|
if (!pos) {
|
||||||
|
reply('No position found, sorry.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
audio.seek(pos)
|
||||||
|
reply(`Resumed at ${pos} ms of track '${track.title()}'`)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,28 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'Follow Me',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3', 'discord'],
|
||||||
|
description: 'The bot will follow the movements of any of the clients given',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: [{
|
||||||
|
name: 'clientUids',
|
||||||
|
title: 'Comma-separated list of client-UIDs that the bot should follow',
|
||||||
|
type: 'string'
|
||||||
|
}]
|
||||||
|
}, (_, {clientUids}) => {
|
||||||
|
const engine = require('engine')
|
||||||
|
const backend = require('backend')
|
||||||
|
const event = require('event')
|
||||||
|
|
||||||
|
if (!clientUids) {
|
||||||
|
engine.log('No client-UIDs set.')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const uids = clientUids.trim().split(',')
|
||||||
|
event.on('clientMove', ({ client, toChannel }) => {
|
||||||
|
if (toChannel && uids.includes(client.uid())) {
|
||||||
|
backend.getBotClient().moveTo(toChannel)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,21 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'No Recording!',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3'],
|
||||||
|
description: 'This script will kick anyone who attempts to record.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: [{
|
||||||
|
name: 'kickMessage',
|
||||||
|
title: 'The optional kick message.',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'No recording on our server!'
|
||||||
|
}]
|
||||||
|
}, (_, config) => {
|
||||||
|
const event = require('event')
|
||||||
|
|
||||||
|
const kickMessage = config.kickMessage || 'No recording on our server!'
|
||||||
|
|
||||||
|
event.on('clientRecord', client => {
|
||||||
|
client.kickFromServer(kickMessage)
|
||||||
|
})
|
||||||
|
})
|
|
@ -0,0 +1,17 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'Remember Last Channel',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3', 'discord'],
|
||||||
|
description: 'This script will remember, which channel the bot was last moved to and will set it as default channel on join.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: []
|
||||||
|
}, () => {
|
||||||
|
const event = require('event')
|
||||||
|
const engine = require('engine')
|
||||||
|
|
||||||
|
event.on('clientMove', ({ client, toChannel }) => {
|
||||||
|
if (toChannel && client.isSelf()) {
|
||||||
|
engine.setDefaultChannelID(toChannel.id())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
||||||
|
registerPlugin({
|
||||||
|
name: 'Welcome!',
|
||||||
|
version: '3.0.0',
|
||||||
|
backends: ['ts3'],
|
||||||
|
description: 'This plugin will let the bot greet everyone.',
|
||||||
|
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
|
||||||
|
vars: [{
|
||||||
|
name: 'message',
|
||||||
|
title: 'The message that should be displayed. (%n = nickname)',
|
||||||
|
type: 'string'
|
||||||
|
}, {
|
||||||
|
name: 'type',
|
||||||
|
title: 'Message-Type',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
'Private chat',
|
||||||
|
'Poke'
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
}, (_, { message, type }) => {
|
||||||
|
const event = require('event')
|
||||||
|
|
||||||
|
event.on('clientMove', ({ client, fromChannel }) => {
|
||||||
|
let msg = message.replace('%n', client.name())
|
||||||
|
if (!fromChannel) {
|
||||||
|
if (type == '0') {
|
||||||
|
client.chat(msg)
|
||||||
|
} else {
|
||||||
|
client.poke(msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue