mirror of
https://github.com/mii443/ncb-tts-r2.git
synced 2025-08-22 16:15:29 +00:00
reading attachment files, fix database
This commit is contained in:
@ -13,11 +13,15 @@ impl Database {
|
||||
}
|
||||
|
||||
pub async fn get_user_config(&mut self, user_id: u64) -> redis::RedisResult<Option<UserConfig>> {
|
||||
let config: String = self.client.get_connection().unwrap().get(format!("discord_user:{}", user_id)).unwrap_or_default();
|
||||
if let Ok(connection) = self.client.get_connection() {
|
||||
let config: String = connection.get(format!("discord_user:{}", user_id)).unwrap_or_default();
|
||||
|
||||
match serde_json::from_str(&config) {
|
||||
Ok(config) => Ok(Some(config)),
|
||||
Err(_) => Ok(None)
|
||||
match serde_json::from_str(&config) {
|
||||
Ok(config) => Ok(Some(config)),
|
||||
Err(_) => Ok(None)
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ pub async fn voice_state_update(
|
||||
old: Option<VoiceState>,
|
||||
new: VoiceState,
|
||||
) {
|
||||
if new.member.unwrap().user.bot {
|
||||
return;
|
||||
}
|
||||
let guild_id = guild_id.unwrap();
|
||||
|
||||
let storage_lock = {
|
||||
|
@ -19,7 +19,7 @@ use crate::{
|
||||
impl TTSMessage for Message {
|
||||
async fn parse(&self, instance: &mut TTSInstance, _: &Context) -> String {
|
||||
let text = validator::remove_url(self.content.clone());
|
||||
let res = if let Some(before_message) = &instance.before_message {
|
||||
let mut res = if let Some(before_message) = &instance.before_message {
|
||||
if before_message.author.id == self.author.id {
|
||||
text.clone()
|
||||
} else {
|
||||
@ -41,6 +41,10 @@ impl TTSMessage for Message {
|
||||
format!("{}さんの発言<break time=\"200ms\"/>{}", name, text)
|
||||
};
|
||||
|
||||
if self.attachments.len() > 0 {
|
||||
res = format!("{}<break time=\"200ms\"/>{}個の添付ファイル", res, self.attachments.len());
|
||||
}
|
||||
|
||||
instance.before_message = Some(self.clone());
|
||||
|
||||
res
|
||||
|
Reference in New Issue
Block a user