Compare commits
No commits in common. "bf8819590100909229374aa2b90f8e6b100e3153" and "58c92991ebb1286bc60b950fd76223800080de80" have entirely different histories.
bf88195901
...
58c92991eb
18
index.mjs
18
index.mjs
@ -6,10 +6,6 @@ var bot = new Bot({
|
||||
emitEvents: false,
|
||||
emitChatEvents: true
|
||||
});
|
||||
bot.on("error", error => {
|
||||
console.error("bot error", error);
|
||||
});
|
||||
|
||||
await bot.login({
|
||||
identifier: process.env.IDENTIFIER,
|
||||
password: process.env.PASSWORD
|
||||
@ -26,11 +22,7 @@ bot.on("message", async message => {
|
||||
if (message.text.startsWith('/')) {
|
||||
let respond = text => conversation.sendMessage({text});
|
||||
let cmd = message.text.split(' ')[0].slice(1).toLowerCase();
|
||||
let commandList = `/list, /leave, /join, /ping`;
|
||||
switch(cmd) {
|
||||
case "ping":
|
||||
await respond("pong");
|
||||
return;
|
||||
case "list":
|
||||
let {conversations} = await bot.listConversations();
|
||||
await respond(`${conversations.length} members in group chat: ${conversations.map(c => '@' + c.members.find(m => m.did != bot.profile.did).handle).join(', ')}`);
|
||||
@ -40,13 +32,13 @@ bot.on("message", async message => {
|
||||
await conversation.leave();
|
||||
return;
|
||||
case "join":
|
||||
await respond(`You joined the group chat`);
|
||||
await respond(`Welcome to the group chat!`);
|
||||
return;
|
||||
case "ping":
|
||||
await respond("pong");
|
||||
return;
|
||||
case "help":
|
||||
await respond(`Commands: ${commandList}`);
|
||||
return;
|
||||
default:
|
||||
await respond(`Only these commands are accepted: ${commandList}`);
|
||||
await respond(`Commands: /list, /leave, /join, /ping`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user