修复了Matrix登陆问题,现在可以收到指令了
This commit is contained in:
1 parent
ad69931573
commit
9fda014ce6
5 files changed
+568
-37
No files matched your search
+10
-3
@@ -11,7 +11,7 @@ type MessageRx = mpsc::Receiver<MessageEnum>;
|
||||
|
||||
static GLOBAL_CHANNEL: OnceLock<(MessageTx, Mutex<Option<MessageRx>>)> = OnceLock::new();
|
||||
|
||||
fn global_channel() -> &'static (MessageTx, Mutex<Option<MessageRx>>) {
|
||||
pub fn global_channel() -> &'static (MessageTx, Mutex<Option<MessageRx>>) {
|
||||
GLOBAL_CHANNEL.get_or_init(|| {
|
||||
let (tx, rx) = mpsc::channel(100);
|
||||
(tx, Mutex::new(Some(rx)))
|
||||
@@ -92,12 +92,19 @@ impl AttendanceHandler for CommandHandler {
|
||||
|
||||
let mut rx = rx;
|
||||
let bot = Arc::clone(&self.bot);
|
||||
let handle = tokio::spawn(async move {
|
||||
let handle: JoinHandle<()> = tokio::spawn(async move {
|
||||
while let Some(msg) = rx.recv().await {
|
||||
match msg {
|
||||
MessageEnum::StopMessage => break,
|
||||
MessageEnum::MatrixMessage(msg) => {
|
||||
let text = msg.text.trim();
|
||||
let text: &str = msg.text.trim();
|
||||
log::info!(
|
||||
"Received Matrix message (event_id={}, channel_id={}, user_id={}): {}",
|
||||
msg.event_id,
|
||||
msg.channel_id,
|
||||
msg.user_id,
|
||||
msg.text
|
||||
);
|
||||
let Some(command_text) = text.strip_prefix('!') else {
|
||||
continue;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user