mirror of
https://github.com/revanced/revanced-discord-bot.git
synced 2025-04-29 22:14:28 +02:00
fix: check parent channels when thread_option
is present
This commit is contained in:
parent
b470563aab
commit
88902ace64
@ -1,34 +1,34 @@
|
||||
{
|
||||
"$schema": "./configuration.schema.json",
|
||||
"general": {
|
||||
"embed_color": 0,
|
||||
"mute": {
|
||||
"role": 0,
|
||||
"take": [0]
|
||||
"take": [
|
||||
0
|
||||
]
|
||||
},
|
||||
"media_channels": [0],
|
||||
"logging_channel": 0
|
||||
},
|
||||
"administrators": {
|
||||
"roles": [0],
|
||||
"users": [0]
|
||||
"roles": [
|
||||
0
|
||||
],
|
||||
"users": [
|
||||
0
|
||||
]
|
||||
},
|
||||
"thread_introductions": [
|
||||
{
|
||||
"channels": [0],
|
||||
"response": {
|
||||
"message": ""
|
||||
}
|
||||
}
|
||||
],
|
||||
"message_responses": [
|
||||
{
|
||||
"includes": {
|
||||
"channels": [0],
|
||||
"channels": [
|
||||
0
|
||||
],
|
||||
"match": []
|
||||
},
|
||||
"excludes": {
|
||||
"roles": [0],
|
||||
"roles": [
|
||||
0
|
||||
],
|
||||
"match": []
|
||||
},
|
||||
"condition": {
|
||||
@ -38,7 +38,11 @@
|
||||
},
|
||||
"response": {
|
||||
"message": ""
|
||||
},
|
||||
"thread_options": {
|
||||
"lock_on_response": false,
|
||||
"close_on_response": false,
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -14,13 +14,10 @@
|
||||
},
|
||||
"administrators": {
|
||||
"roles": [
|
||||
955220417969262612
|
||||
],
|
||||
"users": [
|
||||
737323631117598811
|
||||
955220417969262612,
|
||||
973886585294704640
|
||||
]
|
||||
},
|
||||
"thread_introductions": [],
|
||||
"message_responses": [
|
||||
{
|
||||
"includes": {
|
||||
@ -40,8 +37,7 @@
|
||||
955220417969262612,
|
||||
952987191401926697,
|
||||
1027874293192863765
|
||||
],
|
||||
"match": []
|
||||
]
|
||||
},
|
||||
"condition": {
|
||||
"user": {
|
||||
@ -94,8 +90,7 @@
|
||||
955220417969262612,
|
||||
952987191401926697,
|
||||
1027874293192863765
|
||||
],
|
||||
"match": []
|
||||
]
|
||||
},
|
||||
"response": {
|
||||
"embed": {
|
||||
@ -311,17 +306,24 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
{
|
||||
"includes": {
|
||||
"channels": [952946952348270626, 954147049832603748],
|
||||
"match": ["(?i)(((video|buffer|play|stuck|work|time|freeze|infinite|1:09|endless|\\sload).*){2,})"]
|
||||
"channels": [
|
||||
952946952348270626,
|
||||
1019635439272992868,
|
||||
954147049832603748
|
||||
],
|
||||
"match": [
|
||||
"(?i)(((video|buffer|play|stuck|work|time|freeze|infinite|1:09|endless|\\sload).*){2,})"
|
||||
]
|
||||
},
|
||||
"excludes": {
|
||||
"roles": [
|
||||
965267139902705744, 955220417969262612, 952987191401926697,
|
||||
965267139902705744,
|
||||
955220417969262612,
|
||||
952987191401926697,
|
||||
1027874293192863765
|
||||
],
|
||||
"match": []
|
||||
]
|
||||
},
|
||||
"response": {
|
||||
"embed": {
|
||||
@ -351,8 +353,11 @@
|
||||
"url": ""
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
"thread_options": {
|
||||
"lock_on_response": true,
|
||||
"close_on_response": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -152,8 +152,6 @@ pub struct Includes {
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Excludes {
|
||||
pub roles: Option<Vec<u64>>,
|
||||
#[serde(rename = "match", with = "serde_regex")]
|
||||
pub match_field: Vec<Regex>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -19,11 +19,18 @@ pub async fn handle_message_response(ctx: &serenity::Context, new_message: &sere
|
||||
let message = &new_message.content;
|
||||
|
||||
for response in responses {
|
||||
// check if the channel is whitelisted
|
||||
if let Some(includes) = &response.includes {
|
||||
if let Some(channels) = &includes.channels {
|
||||
// check if the channel is whitelisted, if not, check if the channel is a thread, if it is check if the parent id is whitelisted
|
||||
if !channels.contains(&new_message.channel_id.0) {
|
||||
continue;
|
||||
if response.thread_options.is_some() {
|
||||
let Some(parent_id) = new_message.channel(&ctx.http).await.unwrap().guild().unwrap().parent_id else { continue; };
|
||||
if !channels.contains(&parent_id.0) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,11 +53,6 @@ pub async fn handle_message_response(ctx: &serenity::Context, new_message: &sere
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// check if the message is not blacklisted
|
||||
if contains_match(&excludes.match_field, message) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(condition) = &response.condition {
|
||||
|
Loading…
x
Reference in New Issue
Block a user