Skip to content

Commit

Permalink
增加help
Browse files Browse the repository at this point in the history
  • Loading branch information
Chikage0o0 committed Oct 15, 2023
1 parent 838ace7 commit 08ab557
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions plugins/qbittorrent/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ pub fn add_listener(room: &matrix::room::Room) {
},
);

room.0.add_event_handler(
|event: OriginalSyncRoomMessageEvent, room: matrix_sdk::room::Room| async move {
if let matrix_sdk::room::Room::Joined(room) = room {
let msg_body = match event.content.msgtype {
MessageType::Text(TextMessageEventContent { body, .. }) => body,
_ => return,
};

let msg_body = msg_body.trim();

if msg_body.is_empty() {
return;
}
if msg_body.starts_with("!qbithelp") {
let room_id = room.room_id().as_str();

let map = ROOM_MAP.get().and_then(|map| map.get(room_id));

if let Some((room, _setting)) = map {
let msg = "!download <magnet_url> - 添加磁力至下载\n!status - 查看下载状态";
room.send_relates_msg(&msg, event.event_id.as_str(), false)
.await
.unwrap_or_else(|e| {
log::error!("send message failed: {}", e);
});
}
}
}
},
);

room.0.add_event_handler(
|event: OriginalSyncRoomMessageEvent, room: matrix_sdk::room::Room| async move {
if let matrix_sdk::room::Room::Joined(room) = room {
Expand Down

0 comments on commit 08ab557

Please sign in to comment.