-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCommands.js
70 lines (62 loc) · 2.31 KB
/
Commands.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
const Command = require("./Ship/Command.js");
const Meets = require("./DataAccess/Meets.js");
const START_WELCOME_MESSAGE = `
Hello, I am SailBot, the helpbot for the severnbronies chat.
For a list of my commands try /help.
You can message me either in private or in @severnbronies
`;
function notImplemented(paramaters,message){
Command.basicReply("Sorry but this method is not yet implemented.",message);
}
module.exports = function(commandSource){
/*Commands TODO:
nextMeet
votes
*/
//Start command
new Command("start",commandSource)
.addHandler(null,null,function(paramaters,message){
Command.basicReply(START_WELCOME_MESSAGE,message);
},Command.nArgs(0,1));
//Upcoming command
new Command("upcoming",commandSource)
.addHandler("","Posts the next upcoming meet",function(parmaters,message){
Meets.getUpcomingMeets().then(upcoming=>{
let reply = upcoming.length?
upcoming.map(m=>m.asMarkdown()).join("\n"):
"They are no announced meets coming up";
message.connection.sendMessage({
chat_id:message.chat.id,
//reply_to_message_id:message.message_id,
parse_mode:"Markdown",
text:reply,
disable_web_page_preview:true,
display_notification:true
});
});
},Command.nArgs(0))
.addHandler("_location(s)_","Filters the meets to the given locations",function(paramaters,message){
Meets.getUpcomingMeetsAt(paramaters).then(upcoming=>{
let reply = upcoming.length?
upcoming.map(m=>m.asMarkdown()).join("\n"):
"They are no announced meets coming up at given locations";
message.connection.sendMessage({
chat_id:message.chat.id,
//reply_to_message_id:message.message_id,
parse_mode:"Markdown",
text:reply,
disable_web_page_preview:true,
display_notification:true
});
});
},Command.atleastArgs(1));
//Easter egg
new Command("⬆⬆⬇⬇⬅➡⬅➡ba",commandSource)
.addHandler(null,null,function(paramaters,message){
message.connection.sendPhoto({
chat_id:message.chat.id,
photo:"https://derpicdn.net/img/view/2015/7/11/934995.png",
caption:"Do ships need sails?"
});
},Command.nArgs(0));
};