-
Notifications
You must be signed in to change notification settings - Fork 0
/
logic.js
88 lines (67 loc) · 2.48 KB
/
logic.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// TODO: receive input message from any connected source
// TODO: retain the message source
// TODO: be able to respond to the message at the source
// TODO: respond / forward response to different source (e.g. twitch => discord)
// TODO:
import { getRandomInt } from './lib.js';
/**
*
* @param {string} message
* @param {function} replyCallback
* @param {object} ctx Contains user metadata
*/
export async function handle(message, replyCallback, ctx = {}) {
if (message === "!spells" || message === '!help') {
return replyCallback("!ping, !trello, !discord, !instagram, !twitter, !bio, !github, !pet, !WhereHeAt?")
}
if (message === '!ping') {
return replyCallback('Pong! ❤️');
}
if (message === '!trello') {
return replyCallback("https://trello.com/invite/b/OzGiGtKO/13f309d7fbb5c6f57692c37d965b1eda/delta");
}
if (message === '!discord') {
return replyCallback("https://discord.gg/8XGtYeZNCf");
}
if (message === '!instagram') {
return replyCallback("https://instagram.com/fatalmerlin");
}
if (message === '!twitter') {
return replyCallback("https://twitter.com/fatalmerlin");
}
if (message === '!bio') {
return replyCallback("https://bio.link/fatatmerlin");
}
if (message === '!youtube') {
return replyCallback("https://www.youtube.com/channel/UCPXUlowZpDwi4NyRhkLf9hQ");
}
if (message === '!github') {
return replyCallback("https://github.com/FatalMerlin/delta");
}
// das_grill
if (message === '!pet' && ctx.username === 'das_grill') {
const pets = [
"Woof ▼・ᴥ・▼",
"Oink (´・(oo)・`)",
"Purrr (=^-ω-^=)",
]
return replyCallback(pets[getRandomInt(0, pets.length - 1)]);
}
// epurdus
if (message === '!WhereHeAt?') {
return replyCallback("@drakontheripper are u here?");
}
let match;
if ((match = message.match(/^!(?:roll|gamble)( (\d+)-(\d+))?/i)) !== null) {
console.log(match);
if (match[1] === undefined) {
return replyCallback("Usage: !roll [number]-[number]");
}
let lower = Number(match[2]);
let upper = Number(match[3]);
// we make sure, that the parameters are sorted correctly
[lower, upper] = [lower, upper].sort()
let result = getRandomInt(lower, upper).toString()
return replyCallback(`${ctx.username || 'unknown'} rolled ${result}!`);
}
}