Skip to content

Commit

Permalink
chore: add new option with_torrent. (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
RinChanNOWWW authored Nov 4, 2023
1 parent be7d772 commit 413c2f6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ api = "http://localhost:8000"
dms = [114514, 1919810]
groups = [114514, 1919810]
delay = 200
with_torrent = true
2 changes: 2 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub struct QQBotConfig {
pub groups: Vec<u64>,
/// The delay between two messages. (ms)
pub delay: u64,
/// If the message contains torrents' URLs.
pub with_torrent: bool,
}

#[derive(Debug, Default, Serialize, Deserialize)]
Expand Down
23 changes: 12 additions & 11 deletions src/notifier/qq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,25 @@ impl QQNotifier {
}

fn wrap_item(notifier: &Notifier, source: &str, item: &Item) -> Vec<Message> {
vec![
Message {
msg_type: "node".to_string(),
data: Data {
sender_name: notifier.conf.name.clone(),
sender_uin: notifier.conf.uin.clone(),
content: format!("{}:\n{} ({})", source, item.title, item.pub_date),
},
let mut messages = vec![Message {
msg_type: "node".to_string(),
data: Data {
sender_name: notifier.conf.name.clone(),
sender_uin: notifier.conf.uin.clone(),
content: format!("{}:\n{} ({})", source, item.title, item.pub_date),
},
Message {
}];
if notifier.conf.with_torrent {
messages.push(Message {
msg_type: "node".to_string(),
data: Data {
sender_name: notifier.conf.name.clone(),
sender_uin: notifier.conf.uin.clone(),
content: item.url.clone(),
},
},
]
});
}
messages
}

async fn send_private_msg(notifier: &Notifier, msg: Vec<Message>) -> Result<()> {
Expand Down

0 comments on commit 413c2f6

Please sign in to comment.