-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Frequency/Auto Settings #39
Comments
Did anyone happen to fork this and implement this feature? Feels kind of useless to have a markov chain bot that can't auto-trigger. |
Did it myself, here's the git diff if you want to give it a try (could do with not being an int, 1% may be too high of a min chance for most use cases) diff --git a/src/config/classes.ts b/src/config/classes.ts
index bb1002f..11dc9c2 100644
--- a/src/config/classes.ts
+++ b/src/config/classes.ts
@@ -163,4 +163,13 @@ export class AppConfig {
@IsOptional()
@IsString()
devGuildId = process.env.DEV_GUILD_ID;
+
+ /**
+ * Specifies the chance in 100 to randomly respond to a message
+ * @example 95
+ * @env RANDOM_CHANCE
+ */
+ @IsOptional()
+ @IsInt()
+ randomChance = process.env.RANDOM_CHANCE ? parseInt(process.env.RANDOM_CHANCE, 10) : 100;
}
diff --git a/src/index.ts b/src/index.ts
index 40953bd..02972bf 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -771,6 +771,15 @@ client.on('messageCreate', async (message) => {
}
if (command === null) {
if (isHumanAuthoredMessage(message)) {
+ // handle random response
+ if ((await isValidChannel(message.channel))) {
+ var chance = Math.random() * 100;
+ if (chance >= (100 - config.randomChance)) {
+ const generatedResponse = await generateResponse(message);
+ await handleResponseMessage(generatedResponse, message);
+ }
+ }
+
if (client.user && message.mentions.has(client.user)) {
L.debug('Responding to mention');
// <@!278354154563567636> how are you doing? You can then build the docker image and import it like this (probably a more efficient way to tag on save but I couldn't be bothered to read the docker docs)
|
Is there any chance there can be some sort of Auto setting? A previous markov bot I was aware of allowed you to set a % chance for every message that was typed by a user in a listened channel to trigger a message from the bot. It created a lot of very fun chaos because the bot would chime in at random times and you never knew when or what was gonna happen. Additionally, if we can get % chance setting for how often it embeds an image instead of it randomly choosing to embed an image alongside its post that would also be wonderful!
The text was updated successfully, but these errors were encountered: