Skip to content

Commit 0d43a04

Browse files
committed
update packages
1 parent 8ea2337 commit 0d43a04

File tree

8 files changed

+1138
-415
lines changed

8 files changed

+1138
-415
lines changed

.DS_Store

2 KB
Binary file not shown.

Cargo.lock

+1,121-394
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ tokio = { version = "1.35", features = ["rt", "rt-multi-thread"] }
99
anyhow = "1.0"
1010
serde_json = { version = "1.0" }
1111
serde = { version = "1.0", features = ["derive"] }
12-
rusttype = "0.9"
13-
imageproc = "0.23"
12+
ab_glyph = "0.2"
13+
imageproc = "0.25"
1414
chrono = "0.4"
1515
warp = "0.3"
16-
flexi_logger = "0.27"
16+
flexi_logger = "0.28"
1717
log = "0.4"
1818

1919
[dependencies.image]
20-
version = "0.24"
20+
version = "0.25"
2121
default-features = false
2222
features = ["jpeg", "png"]
2323

@@ -27,6 +27,6 @@ default-features = false
2727
features = ["client", "gateway", "rustls_backend", "model", "cache"]
2828

2929
[dependencies.reqwest]
30-
version = "0.11"
30+
version = "0.12"
3131
default-features = false
3232
features = ["rustls-tls", "json"]

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM rust:1.75 AS builder
1+
FROM rust:1.79 as builder
22
WORKDIR /usr/src/myapp
33
COPY . .
44
ARG github_token

Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ This bot shows info about your battlefield servers and updates it every 2 minute
55
### Environment items:
66

77
```yaml
8+
token: discord bot token
89
guid: serverid (optional)
910
game: game name (tunguska, casablanca, kingston, bf4)
1011
ownerId: server owner playerid (optional for casablanca and kingston)

src/main.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ impl EventHandler for Handler {
3131
since_empty: false,
3232
previous_request: Vec::new(),
3333
since_player_trigger: 5,
34-
status: String::from(""),
3534
};
3635

3736
let statics = message::Static {
@@ -87,7 +86,7 @@ impl EventHandler for Handler {
8786
warp::serve(hello).run(([0, 0, 0, 0], 3030)).await;
8887
});
8988

90-
// loop in seperate async
89+
// loop in separate async
9190
tokio::spawn(async move {
9291
// set update_avatar to 1 minute ago to allow changing on startup
9392
let mut update_avatar = chrono::Utc::now()

src/message.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct Global {
1212
pub since_empty: bool,
1313
pub previous_request: Vec<i32>,
1414
pub since_player_trigger: i32,
15-
pub status: String,
1615
}
1716

1817
#[derive(Clone, Debug)]

src/server_info.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::message;
2+
use ab_glyph::{FontRef, PxScale};
23
use anyhow::Result;
34
use image::{io::Reader as ImageReader, Rgba};
45
use imageproc::drawing::draw_text_mut;
56
use reqwest::Url;
6-
use rusttype::{Font, Scale};
77
use serde::{Deserialize, Serialize};
88
use serde_json::json;
99
use serenity::{client::Context, gateway::ActivityData};
@@ -304,25 +304,22 @@ pub async fn gen_img(status: ServerInfo, statics: message::Static) -> Result<Str
304304
.decode()?
305305
.brighten(-25);
306306

307-
let font: Font = if &statics.game[..] == "kingston" || &statics.game[..] == "bf2042" {
308-
let font_name = Vec::from(include_bytes!("BF_Modernista-Regular.ttf") as &[u8]);
309-
Font::try_from_vec(font_name).unwrap()
307+
let font: FontRef = if &statics.game[..] == "kingston" || &statics.game[..] == "bf2042" {
308+
FontRef::try_from_slice(include_bytes!("BF_Modernista-Regular.ttf") as &[u8]).unwrap()
310309
} else {
311-
let font_name = Vec::from(include_bytes!("Futura.ttf") as &[u8]);
312-
Font::try_from_vec(font_name).unwrap()
310+
FontRef::try_from_slice(include_bytes!("Futura.ttf") as &[u8]).unwrap()
313311
};
314312

315-
let small_font = Vec::from(include_bytes!("DejaVuSans.ttf") as &[u8]);
316-
let small_font = Font::try_from_vec(small_font).unwrap();
313+
let small_font = FontRef::try_from_slice(include_bytes!("DejaVuSans.ttf") as &[u8]).unwrap();
317314

318-
let img_size = Scale {
315+
let img_size = PxScale {
319316
x: img2.width() as f32,
320317
y: img2.height() as f32,
321318
};
322319
let mut orig_img2 = img2.clone();
323320

324321
// only smallmode
325-
let scale = Scale {
322+
let scale = PxScale {
326323
x: (img2.width() / 3) as f32,
327324
y: (img2.height() as f32 / 1.9),
328325
};
@@ -345,7 +342,7 @@ pub async fn gen_img(status: ServerInfo, statics: message::Static) -> Result<Str
345342
img2.save("./map_mode.jpg")?;
346343

347344
// with favorites except bf5
348-
let small_scale = Scale {
345+
let small_scale = PxScale {
349346
x: (img2.width() / 9) as f32,
350347
y: (img2.height() / 6) as f32,
351348
};
@@ -363,7 +360,7 @@ pub async fn gen_img(status: ServerInfo, statics: message::Static) -> Result<Str
363360
img2.save("./info_image.jpg")?;
364361

365362
// only favorites except bf5
366-
let fav_scale = Scale {
363+
let fav_scale = PxScale {
367364
x: (img2.width() / 7) as f32,
368365
y: (img2.height() as f32) / 4.5,
369366
};

0 commit comments

Comments
 (0)