Name2key, Group chat, Group invite / group invite accept / group invite reject

This commit is contained in:
Casper Warden
2017-12-14 18:22:41 +00:00
parent 65526c6d21
commit eab57f8ced
33 changed files with 526 additions and 21 deletions

View File

@@ -62,6 +62,42 @@ bot.clientEvents.onDisconnected.subscribe((DisconnectEvent) =>
}
});
bot.clientEvents.onGroupChat.subscribe((GroupChatEvent) =>
{
console.log("Group chat: " + GroupChatEvent.fromName + ': ' + GroupChatEvent.message);
if (GroupChatEvent.message === 'marco')
{
console.log("Sending PONG");
bot.clientCommands.comms.sendGroupMessage(GroupChatEvent.groupID, 'polo');
}
});
bot.clientEvents.onGroupInvite.subscribe((GroupInviteEvent) =>
{
console.log('Group invite from ' + GroupInviteEvent.fromName + ': '+GroupInviteEvent.message);
//Resolve avatar key
bot.clientCommands.grid.name2Key(GroupInviteEvent.fromName).then((key) =>
{
if (key.toString() === master)
{
console.log('Accepting');
bot.clientCommands.comms.acceptGroupInvite(GroupInviteEvent);
}
else
{
console.log('Unauthorised - rejecting');
bot.clientCommands.comms.rejectGroupInvite(GroupInviteEvent);
}
}).catch((err) =>
{
console.error(err);
console.log('Unknown avatar - rejecting');
bot.clientCommands.comms.rejectGroupInvite(GroupInviteEvent);
});
});
function connect()
{
console.log("Logging in..");
@@ -96,6 +132,10 @@ connect();
function exitHandler(options, err)
{
if (err)
{
console.log(err.stack);
}
if (isConnected)
{
console.log("Disconnecting");
@@ -105,10 +145,6 @@ function exitHandler(options, err)
});
return;
}
if (err)
{
console.log(err.stack);
}
if (options.exit)
{
process.exit();