mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-25 17:35:25 +02:00
handle busy conversation
This commit is contained in:
parent
2c0467b658
commit
ffb09bc3bd
1 changed files with 8 additions and 5 deletions
|
@ -121,6 +121,13 @@ export function sendToBot(send_to, message, start=false) {
|
||||||
|
|
||||||
export async function recieveFromBot(sender, json) {
|
export async function recieveFromBot(sender, json) {
|
||||||
const convo = _getConvo(sender);
|
const convo = _getConvo(sender);
|
||||||
|
|
||||||
|
// check if any convo is active besides the sender
|
||||||
|
if (Object.values(convos).some(c => c.active && c.name !== sender)) {
|
||||||
|
sendToBot(sender, 'I am currently busy. Try again later. !endConversation("' + sender + '")');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`decoding **${json}**`);
|
console.log(`decoding **${json}**`);
|
||||||
const recieved = JSON.parse(json);
|
const recieved = JSON.parse(json);
|
||||||
if (recieved.start) {
|
if (recieved.start) {
|
||||||
|
@ -216,12 +223,8 @@ function _handleFullInMessage(sender, recieved) {
|
||||||
convo.active = true;
|
convo.active = true;
|
||||||
|
|
||||||
const message = _tagMessage(recieved.message);
|
const message = _tagMessage(recieved.message);
|
||||||
if (recieved.end) {
|
if (recieved.end)
|
||||||
convo.end();
|
convo.end();
|
||||||
// if end signal from other bot, add to history but don't respond
|
|
||||||
agent.history.add(sender, message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (recieved.start)
|
if (recieved.start)
|
||||||
agent.shut_up = false;
|
agent.shut_up = false;
|
||||||
convo.inMessageTimer = null;
|
convo.inMessageTimer = null;
|
||||||
|
|
Loading…
Add table
Reference in a new issue