Siren OAI creates thread if possible for conversations

This commit is contained in:
2023-07-07 12:24:04 -04:00
parent b09b09453a
commit 7d94f07329
2 changed files with 17 additions and 5 deletions

View File

@@ -2,13 +2,13 @@ version: '3'
services: services:
siren: siren:
image: siren:${SIREN_VERSION} image: siren:${SIREN_VERSION:-latest}
container_name: siren container_name: siren
build: build:
context: . context: .
dockerfile: ./Dockerfile dockerfile: ./Dockerfile
args: args:
- VERSION=${SIREN_VERSION} - VERSION=${SIREN_VERSION:-latest}
volumes: volumes:
- ./app:/siren - ./app:/siren
environment: environment:

View File

@@ -9,6 +9,7 @@ use log::{error, debug, trace, warn};
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use serde_json::Value; use serde_json::Value;
use serenity::model::channel::Message; use serenity::model::channel::Message;
use serenity::model::prelude::ChannelType;
use serenity::prelude::*; use serenity::prelude::*;
use crate::database::models::{NewMessageDB, MessageDB}; use crate::database::models::{NewMessageDB, MessageDB};
@@ -288,7 +289,18 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI, pool: &P
// Stop the typing indicator and send the response // Stop the typing indicator and send the response
typing.stop(); typing.stop();
if let Err(why) = msg.channel_id.say(&ctx.http, response).await { match msg.channel_id.create_public_thread(&ctx.http, msg.id, |thread| {
error!("Cannot send message: {}", why); thread.name("Siren Response").kind(ChannelType::PublicThread)
} }).await {
Ok(c) => {
if let Err(why) = c.say(&ctx.http, response).await {
error!("Cannot send message: {}", why);
}
}
Err(_) => {
if let Err(why) = channel_id.say(&ctx.http, response).await {
error!("Cannot send message: {}", why);
}
}
};
} }