Siren OAI creates thread if possible for conversations
This commit is contained in:
@@ -2,13 +2,13 @@ version: '3'
|
||||
|
||||
services:
|
||||
siren:
|
||||
image: siren:${SIREN_VERSION}
|
||||
image: siren:${SIREN_VERSION:-latest}
|
||||
container_name: siren
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
args:
|
||||
- VERSION=${SIREN_VERSION}
|
||||
- VERSION=${SIREN_VERSION:-latest}
|
||||
volumes:
|
||||
- ./app:/siren
|
||||
environment:
|
||||
|
||||
@@ -9,6 +9,7 @@ use log::{error, debug, trace, warn};
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde_json::Value;
|
||||
use serenity::model::channel::Message;
|
||||
use serenity::model::prelude::ChannelType;
|
||||
use serenity::prelude::*;
|
||||
|
||||
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
|
||||
typing.stop();
|
||||
if let Err(why) = msg.channel_id.say(&ctx.http, response).await {
|
||||
error!("Cannot send message: {}", why);
|
||||
}
|
||||
match msg.channel_id.create_public_thread(&ctx.http, msg.id, |thread| {
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user