first version of Help component

This commit is contained in:
Sebastian Korotkiewicz 2022-03-27 03:39:26 +02:00
parent 4f93adf525
commit a084196c0e
Signed by: grizzly
GPG Key ID: 5BDC557B496BDB0D
2 changed files with 38 additions and 5 deletions

35
components/Help.js Normal file
View File

@ -0,0 +1,35 @@
const Help = (event) => {
let msg = event.message;
let cmd = msg.match(/^,help (\w+)?$/);
if (!cmd || !cmd[1]) {
event.reply(",help commands - show all avalible commands");
return;
}
switch (cmd[1]) {
case "w":
event.reply(",w [location] - show weather for you city");
event.reply(",w set [location] - save your location");
event.reply(",w - after your save your location you can use ,w");
break;
case "commands":
event.reply(",help [command] for details");
event.reply("avalible commands: w");
event.reply(" ,help w");
break;
default:
event.reply(",help - show this message");
break;
}
};
// let msg = ",help w";
// let cmd = msg.match(/^,help (\w+)?$/);
// console.log(cmd);
export default Help;

View File

@ -1,7 +1,8 @@
import { Client } from "irc-framework";
import InitDB from "./components/db.js";
import Weather from "./components/Weather.js";
import UrlTitle from "./components/UrlTitle.js";
import InitDB from "./components/db.js";
import Help from "./components/Help.js";
InitDB();
@ -43,8 +44,5 @@ bot.matchMessage(/^,w/, async (event) => {
});
bot.matchMessage(/^,help/, (event) => {
event.reply(",help - show this message");
event.reply(",w [location] - show weather for you city");
event.reply(",w set [location] - save your location");
event.reply(",w - after your save your location you can use ,w");
return Help(event);
});