Skip to content

Commit

Permalink
remove unused mutable references and sort Cargo.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
jelni committed Jun 4, 2024
1 parent 32b33e1 commit a1aaa00
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 31 deletions.
41 changes: 22 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,32 @@ name = "craiyon-bot"
version = "1.0.0"
edition = "2021"

[dependencies]
markov-chain = { git = "https://github.com/JelNiSlaw/markov-chain" }
[lints.clippy]
pedantic = "warn"
nursery = "warn"

tdlib = { git = "https://github.com/JelNiSlaw/tdlib-rs-latest" }
tokio = { version = "1.37", features = ["rt-multi-thread", "macros", "time", "signal"] }
[dependencies]
async-signal = "0.2"
async-trait = "0.1"
reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls"] }
url = "2.3"
serde = "1.0"
serde_json = "1.0"
rmp-serde = "1.1"
base64 = "0.22"
bytes = "1.4"
charname = "0.2"
colored = "2.0"
counter = "0.5"
dotenvy = "0.15"
futures-util = "0.3"
oneshot = "0.1"
image = { version = "0.25", default-features = false, features = ["jpeg", "png", "webp"] }
base64 = "0.22"
md5 = "0.7"
time = { version = "0.3", features = ["serde", "serde-well-known", "macros"] }
dotenvy = "0.15"
tempfile = "3.4"
async-signal = "0.2"
log = { version = "0.4", features = ["std"] }
colored = "2.0"
markov-chain = { git = "https://github.com/JelNiSlaw/markov-chain" }
md5 = "0.7"
oneshot = "0.1"
rand = "0.9.0-alpha"
counter = "0.5"
charname = "0.2"
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] }
rmp-serde = "1.1"
serde = "1.0"
serde_json = "1.0"
tdlib = { git = "https://github.com/JelNiSlaw/tdlib-rs-latest" }
tempfile = "3.4"
time = { version = "0.3", features = ["macros", "serde", "serde-well-known"] }
tokio = { version = "1.37", features = ["macros", "rt-multi-thread", "signal", "time"] }
url = "2.3"
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
format_code_in_doc_comments = true
hex_literal_case = "Upper"
hex_literal_case = "Lower"
imports_granularity = "Module"
newline_style = "Unix"
normalize_comments = true
Expand Down
14 changes: 7 additions & 7 deletions src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl Bot {
));
}

fn on_chat_member(&mut self, update: UpdateChatMember) {
fn on_chat_member(&self, update: UpdateChatMember) {
if let MessageSender::User(user) = &update.new_chat_member.member_id {
if self.my_id.is_some_and(|my_id| user.user_id == my_id) {
if let Some(chat) = self.state.cache.lock().unwrap().get_chat(update.chat_id) {
Expand All @@ -247,27 +247,27 @@ impl Bot {
self.state.cache.lock().unwrap().update_chat_member(update);
}

fn on_message_send_succeeded(&mut self, update: UpdateMessageSendSucceeded) {
fn on_message_send_succeeded(&self, update: UpdateMessageSendSucceeded) {
self.state.message_queue.message_sent(Ok(update));
}

fn on_message_send_failed(&mut self, update: UpdateMessageSendFailed) {
fn on_message_send_failed(&self, update: UpdateMessageSendFailed) {
self.state.message_queue.message_sent(Err(update));
}

fn on_new_chat(&mut self, update: UpdateNewChat) {
fn on_new_chat(&self, update: UpdateNewChat) {
self.state.cache.lock().unwrap().update_new_chat(update);
}

fn on_chat_title(&mut self, update: UpdateChatTitle) {
fn on_chat_title(&self, update: UpdateChatTitle) {
self.state.cache.lock().unwrap().update_chat_title(update);
}

fn on_chat_permissions(&mut self, update: UpdateChatPermissions) {
fn on_chat_permissions(&self, update: UpdateChatPermissions) {
self.state.cache.lock().unwrap().update_chat_permissions(update);
}

fn on_user(&mut self, update: UpdateUser) {
fn on_user(&self, update: UpdateUser) {
if self.my_id.is_some_and(|my_id| update.user.id == my_id) {
let user = CompactUser::from(update.user.clone());
log::info!("running as {user}");
Expand Down
2 changes: 0 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![warn(clippy::pedantic, clippy::nursery)]

use bot::Bot;
use utilities::logchamp;

Expand Down
4 changes: 2 additions & 2 deletions src/utilities/message_entities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ pub trait Utf16Len {
impl Utf16Len for str {
fn utf16_len(&self) -> usize {
self.bytes()
.filter(|byte| (byte & 0xC0) != 0x80)
.map(|byte| if byte >= 0xF0 { 2 } else { 1 })
.filter(|byte| (byte & 0xc0) != 0x80)
.map(|byte| if byte >= 0xf0 { 2 } else { 1 })
.sum()
}
}
Expand Down

0 comments on commit a1aaa00

Please sign in to comment.