Siren OAI creates thread if possible for conversations
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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| {
|
||||||
|
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);
|
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