Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

way for bots to have cool down periods (dynamic tempature adjusts) & only direct reply setting #399

Closed
o-on-x opened this issue Nov 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@o-on-x
Copy link
Contributor

o-on-x commented Nov 18, 2024

to add for for .env

#DISCORD | only respond when @ | cooldown on reply in MS
DISCORD_DIRECT_ONLY=true #true
DISCORD_COOLDOWN=0 #default 1 min (only applies when not direct @)

to add for messages.ts discord

async handleMessage(message: DiscordMessage) {
        if (
            message.interaction ||
            message.author.id ===
                this.client.user?.id /* || message.author?.bot*/
        )
            return;
    //only respond too direct @ or replys
    const isDirectMention = message.mentions.has(this.client.user?.id);
    const isReplyToBot = message.reference?.messageId && (
        await message.channel.messages.fetch(message.reference.messageId)
    ).author.id === this.client.user?.id;
    const isDirectInteraction = isDirectMention || isReplyToBot;
    if (settings.DISCORD_DIRECT_ONLY && !isDirectInteraction) {
        console.log("Direct-only mode: ignoring non-mention message");
        return;
    }
        if (isReplyToBot) {
        console.log("Reply to bot detected");
    }

    // Only apply cooldown check for non-direct mentions
    if (!isDirectInteraction) {
        const timeSinceLastResponse = Date.now() - this.lastResponseTime;
        
        if (timeSinceLastResponse < this.COOLDOWN_MS) {
            console.log(`Cooling down for non-direct messages. Time remaining: ${(this.COOLDOWN_MS - timeSinceLastResponse)/1000}s`);
            return;
        }
        
    } else {
        console.log("Direct mention detected - bypassing cooldown");
    }

.....
                await this.runtime.processActions(
                    memory,
                    responseMessages,
                    state,
                    callback
                );
                this.lastResponseTime = Date.now(); 
                
            }
@SecretRecipe
Copy link

Does something like this exist for X/twitter too? It would be cool to be able to set the agent's to be more "choose-y" and not just reply to everything that's specified all the time.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants