-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read config constants from config.rs and minor code improvements
- Loading branch information
1 parent
74cd002
commit dbf5884
Showing
4 changed files
with
110 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
pub const MTPROTO_SOURCES: &[&str] = &["https://t.me/s/NextGenProxy", "https://t.me/s/MTP_roto"]; | ||
pub const SHADOWSOCKS_SOURCES: &[&str] = | ||
&["https://raw.githubusercontent.com/barry-far/V2ray-Configs/main/All_Configs_Sub.txt"]; | ||
|
||
pub const VMESS_SOURCES: &[&str] = | ||
&["https://raw.githubusercontent.com/barry-far/V2ray-Configs/main/All_Configs_Sub.txt"]; | ||
|
||
pub const VLESS_SOURCES: &[&str] = | ||
&["https://raw.githubusercontent.com/barry-far/V2ray-Configs/main/All_Configs_Sub.txt"]; | ||
|
||
pub const TROJAN_SOURCES: &[&str] = | ||
&["https://raw.githubusercontent.com/barry-far/V2ray-Configs/main/All_Configs_Sub.txt"]; | ||
|
||
pub const HELP_MESSAGE: &str = "Fire Ninja Bot allows you to access proxies to bypass firewalls and access blocked content. Currently, only the following commands are available: | ||
- /help: Shows this message. | ||
- /mtproxy: Fetches and provides a list of MTProto proxies. | ||
- /shadowsocks: Fetches and provides a list of Shadowsocks proxies. | ||
- /vmess: Fetches and provides a list of VMess proxies. | ||
- /vless: Fetches and provides a list of VLess proxies. | ||
- /trojan: Fetches and provides a list of Trojan proxies. | ||
"; | ||
|
||
pub const INVALID_COMMAND_MESSAGE: &str = | ||
"Invalid command, use /help to get list of available commands."; | ||
|
||
pub const NO_PROXIES_FOUND_MESSAGE: &str = "No proxies were found."; | ||
|
||
pub const LINE_SEPERATOR: &str = "\n﹌﹌﹌\n"; | ||
|
||
pub const MTPROXY_COMMAND: &str = "/mtproxy"; | ||
pub const SHADOWSOCKS_COMMAND: &str = "/shadowsocks"; | ||
pub const VMESS_COMMAND: &str = "/vmess"; | ||
pub const VLESS_COMMAND: &str = "/vless"; | ||
pub const TROJAN_COMMAND: &str = "/trojan"; | ||
pub const HELP_COMMAND: &str = "/help"; | ||
pub const START_COMMAND: &str = "/start"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::{json, Value as JsonValue}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct TelegramUpdate { | ||
pub message: Option<TelegramMessage>, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct TelegramMessage { | ||
pub chat: TelegramChat, | ||
pub text: String, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct TelegramChat { | ||
pub id: i64, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct TelegramSendMessage { | ||
pub chat_id: i64, | ||
pub text: String, | ||
pub parse_mode: String, | ||
} | ||
|
||
impl TelegramSendMessage { | ||
pub fn new_md(chat_id: i64, text: String) -> Self { | ||
TelegramSendMessage { | ||
chat_id, | ||
text, | ||
parse_mode: "Markdown".to_string(), | ||
} | ||
} | ||
|
||
pub fn to_json(&self) -> JsonValue { | ||
json!({ | ||
"method": "sendMessage", | ||
"chat_id": self.chat_id, | ||
"text": self.text, | ||
"parse_mode": self.parse_mode, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
pub async fn fetch_sources(sources: &[&str]) -> String { | ||
let mut content = String::new(); | ||
for source in sources { | ||
if let Ok(response) = reqwest::get(*source).await { | ||
if let Ok(text) = response.text().await { | ||
content.push_str(&text); | ||
} | ||
} | ||
} | ||
|
||
content | ||
} |