shirabe-core 0.1.0

A Satori Bot Framework Core For Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
#[cfg(test)]
mod tests {
    use shirabe_core::bot::Bot;
    use shirabe_core::command::{
        Command, CommandAction, CommandBuilder, CommandRegistry, ParsedArgs,
    };
    use shirabe_core::context::Context;
    use shirabe_core::context::filter::ContextFilter;
    use shirabe_core::context::state::EventSystemSharedState;
    use shirabe_core::error::{FrameworkError, FrameworkResult};
    use shirabe_core::message::MessageElement;
    use shirabe_core::session::{Session, SessionEvent};
    use shirabe_core::types::{
        Channel, ChannelType, Guild, GuildMember, GuildRole, Login, LoginStatus,
        Message as FrameworkMessage, User,
    };
    use std::collections::HashMap;
    use std::sync::{Arc, Mutex, RwLock};

    fn create_test_session(
        platform: &str,
        user_id: &str,
        guild_id: &str,
        channel_id: &str,
        is_direct: bool,
        message_text_content: &str,
        message_elements: Vec<MessageElement>,
    ) -> Arc<Session> {
        let shared_state = Arc::new(RwLock::new(EventSystemSharedState::default()));
        let app_context = Arc::new(Context::new_root(shared_state));

        #[derive(Debug)]
        struct DummyAdapter;
        #[async_trait::async_trait]
        impl shirabe_core::adapter::Adapter for DummyAdapter {
            fn get_name(&self) -> String {
                "dummy".to_string()
            }
            async fn connect(&self, _bot: Arc<Bot>) {}
            async fn disconnect(&self, _bot: Arc<Bot>) {}
            async fn create_reaction(&self, _: &str, _: &str, _: &str) -> FrameworkResult<()> {
                Ok(())
            }
            async fn delete_reaction(
                &self,
                _: &str,
                _: &str,
                _: &str,
                _: &str,
            ) -> FrameworkResult<()> {
                Ok(())
            }
            async fn clear_reaction(&self, _: &str, _: &str, _: &str) -> FrameworkResult<()> {
                Ok(())
            }
            async fn get_reaction_list(
                &self,
                _: &str,
                _: &str,
                _: &str,
                _: Option<&str>,
            ) -> FrameworkResult<Vec<User>> {
                Ok(vec![])
            }
            async fn get_channel(&self, _: &str) -> FrameworkResult<Channel> {
                unimplemented!()
            }
            async fn get_channel_list(
                &self,
                _: &str,
                _: Option<&str>,
            ) -> FrameworkResult<Vec<Channel>> {
                unimplemented!()
            }
            async fn create_channel(&self, _: &str, _: Channel) -> FrameworkResult<Channel> {
                unimplemented!()
            }
            async fn update_channel(&self, _: &str, _: Channel) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn delete_channel(&self, _: &str) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn create_direct_channel(&self, _: &str) -> FrameworkResult<Channel> {
                unimplemented!()
            }
            async fn set_guild_member_role(
                &self,
                _: &str,
                _: &str,
                _: &str,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn unset_guild_member_role(
                &self,
                _: &str,
                _: &str,
                _: &str,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn get_guild_member_role_list(
                &self,
                _: &str,
                _: Option<&str>,
            ) -> FrameworkResult<Vec<GuildRole>> {
                unimplemented!()
            }
            async fn create_guild_role(&self, _: &str, _: &str) -> FrameworkResult<GuildRole> {
                unimplemented!()
            }
            async fn update_guild_role(
                &self,
                _: &str,
                _: &str,
                _: GuildRole,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn delete_guild_role(&self, _: &str, _: &str) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn send_message(
                &self,
                _channel_id: &str,
                _elements: &[MessageElement],
            ) -> FrameworkResult<Vec<String>> {
                Ok(vec![])
            }
            async fn send_private_message(
                &self,
                _: &str,
                _: &str,
                _: &[MessageElement],
            ) -> FrameworkResult<Vec<String>> {
                unimplemented!()
            }
            async fn get_message(&self, _: &str, _: &str) -> FrameworkResult<FrameworkMessage> {
                unimplemented!()
            }
            async fn delete_message(&self, _: &str, _: &str) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn update_message(
                &self,
                _: &str,
                _: &str,
                _: &[MessageElement],
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn get_message_list(
                &self,
                _: &str,
                _: Option<&str>,
                _: Option<&str>,
            ) -> FrameworkResult<Vec<FrameworkMessage>> {
                unimplemented!()
            }
            async fn get_user(&self, _: &str) -> FrameworkResult<User> {
                unimplemented!()
            }
            async fn get_friends(&self, _: Option<&str>) -> FrameworkResult<Vec<User>> {
                unimplemented!()
            }
            async fn handle_friend_request(
                &self,
                _: &str,
                _: bool,
                _: Option<&str>,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn get_guild(&self, _: &str) -> FrameworkResult<Guild> {
                unimplemented!()
            }
            async fn get_guilds(&self, _: Option<&str>) -> FrameworkResult<Vec<Guild>> {
                unimplemented!()
            }
            async fn handle_guild_invite(
                &self,
                _: &str,
                _: bool,
                _: Option<&str>,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn get_guild_member(&self, _: &str, _: &str) -> FrameworkResult<GuildMember> {
                unimplemented!()
            }
            async fn get_guild_members(
                &self,
                _: &str,
                _: Option<&str>,
            ) -> FrameworkResult<Vec<GuildMember>> {
                unimplemented!()
            }
            async fn kick_guild_member(
                &self,
                _: &str,
                _: &str,
                _: Option<bool>,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn mute_guild_member(
                &self,
                _: &str,
                _: &str,
                _: Option<u64>,
                _: &str,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn handle_guild_request(
                &self,
                _: &str,
                _: bool,
                _: Option<&str>,
            ) -> FrameworkResult<()> {
                unimplemented!()
            }
            async fn get_login(&self) -> FrameworkResult<Login> {
                unimplemented!()
            }
        }
        let adapter = Arc::new(DummyAdapter);

        let bot = Arc::new(Bot::new(app_context, adapter));
        let event = SessionEvent {
            id: 1,
            ty: "message.created".to_string(),
            platform: platform.to_string(),
            self_id: "test_bot_id".to_string(),
            timestamp: 0,
            channel: Channel {
                id: channel_id.to_string(),
                ty: if is_direct {
                    ChannelType::Direct
                } else {
                    ChannelType::Text
                },
                name: "test_channel".to_string(),
                parent_id: None,
            },
            guild: Guild {
                id: guild_id.to_string(),
                name: "test_guild".to_string(),
                avatar: None,
            },
            login: Login {
                // Add dummy Login
                sn: 0,
                platform: Some(platform.to_string()),
                user: Some(User {
                    id: "test_bot_id".to_string(),
                    ..Default::default()
                }),
                status: LoginStatus::Online,
                adapter: "dummy".to_string(),
                features: vec![],
            },
            member: Default::default(), // GuildMember
            message: FrameworkMessage {
                id: "test_msg_id".to_string(),
                content: message_text_content.to_string(),
                elements: message_elements,
                channel: Some(Channel {
                    id: channel_id.to_string(),
                    ty: if is_direct {
                        ChannelType::Direct
                    } else {
                        ChannelType::Text
                    },
                    name: "test_channel".to_string(),
                    parent_id: None,
                }),
                guild: Some(Guild {
                    id: guild_id.to_string(),
                    name: "test_guild".to_string(),
                    avatar: None,
                }),
                member: None,
                quote: None,
                user: Some(User {
                    id: user_id.to_string(),
                    name: Some("test_user".to_string()),
                    ..Default::default()
                }),
                created_at_ms: Some(0),
                updated_at_ms: Some(0),
            },
            operator: Default::default(),
            role: Default::default(),
            user: User {
                id: user_id.to_string(),
                name: Some("test_user".to_string()),
                ..Default::default()
            },
        };
        Arc::new(Session::new(bot, event))
    }

    fn create_empty_action() -> CommandAction {
        Box::new(|_session, _args| Box::pin(async { Ok(()) }))
    }

    #[test]
    fn test_register_command() {
        let mut registry = CommandRegistry::new();
        let cmd = Command {
            name: "testcmd".to_string(),
            aliases: vec!["tc".to_string()],
            description: None,
            filter: ContextFilter::new(),
            action: create_empty_action(),
        };
        registry.register(cmd).unwrap();

        assert!(registry.commands.contains_key("testcmd"));
        assert!(registry.commands.contains_key("tc"));
        assert_eq!(registry.commands.get("testcmd").unwrap().name, "testcmd");
        assert_eq!(registry.commands.get("tc").unwrap().name, "testcmd");
    }

    #[test]
    fn test_register_overwrite_command() {
        let mut registry = CommandRegistry::new();
        let cmd1 = Command {
            name: "testcmd".to_string(),
            aliases: vec![],
            description: Some("First version".to_string()),
            filter: ContextFilter::new(),
            action: create_empty_action(),
        };
        registry.register(cmd1).unwrap();
        assert_eq!(
            registry.commands.get("testcmd").unwrap().description,
            Some("First version".to_string())
        );

        let cmd2 = Command {
            name: "testcmd".to_string(),
            aliases: vec![],
            description: Some("Second version".to_string()),
            filter: ContextFilter::new(),
            action: create_empty_action(),
        };
        registry.register(cmd2).unwrap();
        assert_eq!(
            registry.commands.get("testcmd").unwrap().description,
            Some("Second version".to_string())
        );
    }

    #[tokio::test]
    async fn test_parse_and_execute_no_prefix() {
        let registry = CommandRegistry::new();
        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "testcmd arg1",
            vec![],
        );
        let prefixes = ["/", "!"];
        let executed = registry
            .parse_and_execute(session, "testcmd arg1", &prefixes)
            .await
            .unwrap();
        assert!(!executed);
    }

    #[tokio::test]
    async fn test_parse_and_execute_only_prefix() {
        let registry = CommandRegistry::new();
        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/",
            vec![],
        );
        let prefixes = ["/", "!"];
        let executed = registry
            .parse_and_execute(session, "/", &prefixes)
            .await
            .unwrap();
        assert!(!executed);
    }

    #[tokio::test]
    async fn test_parse_and_execute_unknown_command() {
        let registry = CommandRegistry::new();
        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/unknown",
            vec![],
        );
        let prefixes = ["/", "!"];
        let executed = registry
            .parse_and_execute(session, "/unknown", &prefixes)
            .await
            .unwrap();
        assert!(!executed);
    }

    #[tokio::test]
    async fn test_parse_and_execute_simple_command() {
        let mut registry = CommandRegistry::new();
        let executed_flag = Arc::new(Mutex::new(false));
        let flag_clone = Arc::clone(&executed_flag);

        let cmd = Command {
            name: "ping".to_string(),
            aliases: vec![],
            description: None,
            filter: ContextFilter::new(),
            action: Box::new(move |_session, _args| {
                let mut flag = flag_clone.lock().unwrap();
                *flag = true;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/ping",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry
            .parse_and_execute(session, "/ping", &prefixes)
            .await
            .unwrap();

        assert!(executed);
        assert!(*executed_flag.lock().unwrap());
    }

    #[tokio::test]
    async fn test_parse_and_execute_command_with_args() {
        let mut registry = CommandRegistry::new();
        let received_args = Arc::new(Mutex::new(Vec::new()));
        let args_clone = Arc::clone(&received_args);

        let cmd = Command {
            name: "echo".to_string(),
            aliases: vec![],
            description: None,
            filter: ContextFilter::new(),
            action: Box::new(move |_session, args| {
                let mut received = args_clone.lock().unwrap();
                *received = args.arguments;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "!echo hello world",
            vec![],
        );
        let prefixes = ["!"];
        let executed = registry
            .parse_and_execute(session, "!echo hello world", &prefixes)
            .await
            .unwrap();

        assert!(executed);
        assert_eq!(
            *received_args.lock().unwrap(),
            vec!["hello".to_string(), "world".to_string()]
        );
    }

    #[tokio::test]
    async fn test_parse_and_execute_command_with_options() {
        let mut registry = CommandRegistry::new();
        let received_options = Arc::new(Mutex::new(HashMap::new()));
        let options_clone = Arc::clone(&received_options);

        let cmd = Command {
            name: "greet".to_string(),
            aliases: vec![],
            description: None,
            filter: ContextFilter::new(),
            action: Box::new(move |_session, args| {
                let mut received = options_clone.lock().unwrap();
                *received = args.options;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/greet --name Alice --loud",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry
            .parse_and_execute(session, "/greet --name Alice --loud", &prefixes)
            .await
            .unwrap();

        assert!(executed);
        let options = received_options.lock().unwrap();
        assert_eq!(options.get("name"), Some(&"Alice".to_string()));
        assert_eq!(options.get("loud"), Some(&"".to_string()));
    }

    #[tokio::test]
    async fn test_parse_and_execute_command_with_short_options() {
        let mut registry = CommandRegistry::new();
        let received_options = Arc::new(Mutex::new(HashMap::new()));
        let options_clone = Arc::clone(&received_options);

        let cmd = Command {
            name: "shortgreet".to_string(),
            aliases: vec![],
            description: None,
            filter: ContextFilter::new(),
            action: Box::new(move |_session, args| {
                let mut received = options_clone.lock().unwrap();
                *received = args.options;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/shortgreet -v -x arg1 --mode test -abc",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry
            .parse_and_execute(
                session,
                "/shortgreet -v -x arg1 --mode test -abc",
                &prefixes,
            )
            .await
            .unwrap();

        assert!(executed);
        let options = received_options.lock().unwrap();
        assert_eq!(options.get("v"), Some(&"".to_string()));
        assert_eq!(options.get("x"), Some(&"".to_string()));
        assert_eq!(options.get("a"), Some(&"".to_string()));
        assert_eq!(options.get("b"), Some(&"".to_string()));
        assert_eq!(options.get("c"), Some(&"".to_string()));
        assert_eq!(options.get("mode"), Some(&"test".to_string()));
    }

    #[tokio::test]
    async fn test_parse_and_execute_command_with_mixed_args_and_options() {
        let mut registry = CommandRegistry::new();
        let received_data = Arc::new(Mutex::new(ParsedArgs::default()));
        let data_clone = Arc::clone(&received_data);

        let cmd = Command {
            name: "mix".to_string(),
            aliases: vec![],
            description: None,
            filter: ContextFilter::new(),
            action: Box::new(move |_session, args| {
                let mut received = data_clone.lock().unwrap();
                *received = args;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/mix arg1 --opt1 val1 arg2 --flag -s arg3",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry
            .parse_and_execute(
                session,
                "/mix arg1 --opt1 val1 arg2 --flag -s arg3",
                &prefixes,
            )
            .await
            .unwrap();

        assert!(executed);
        let parsed_args = received_data.lock().unwrap();
        assert_eq!(
            parsed_args.arguments,
            vec!["arg1".to_string(), "arg2".to_string(), "arg3".to_string()]
        );
        assert_eq!(parsed_args.options.get("opt1"), Some(&"val1".to_string()));
        assert_eq!(parsed_args.options.get("flag"), Some(&"".to_string()));
        assert_eq!(parsed_args.options.get("s"), Some(&"".to_string()));
    }

    #[tokio::test]
    async fn test_command_builder_register() {
        let shared_state = Arc::new(RwLock::new(EventSystemSharedState::default()));
        let registry_arc = Arc::clone(&shared_state.read().unwrap().command_registry);

        let executed_flag = Arc::new(Mutex::new(false));
        let flag_clone = Arc::clone(&executed_flag);

        CommandBuilder::new(
            "builtcmd".to_string(),
            ContextFilter::new(),
            Arc::clone(&registry_arc),
        )
        .alias("bc")
        .description("A built command")
        .action(move |_session, _args| {
            let mut flag = flag_clone.lock().unwrap();
            *flag = true;
            Box::pin(async { Ok(()) })
        })
        .register()
        .unwrap();

        let registry_guard = registry_arc.read().unwrap();
        assert!(registry_guard.commands.contains_key("builtcmd"));
        assert!(registry_guard.commands.contains_key("bc"));
        assert_eq!(
            registry_guard.commands.get("builtcmd").unwrap().description,
            Some("A built command".to_string())
        );

        // Test execution
        let session = create_test_session(
            "test_platform",
            "user1",
            "guild1",
            "channel1",
            false,
            "/builtcmd",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry_guard
            .parse_and_execute(session, "/builtcmd", &prefixes)
            .await
            .unwrap();

        assert!(executed);
        assert!(*executed_flag.lock().unwrap());
    }

    #[test]
    fn test_command_builder_no_action_error() {
        let shared_state = Arc::new(RwLock::new(EventSystemSharedState::default()));
        let registry_arc = Arc::clone(&shared_state.read().unwrap().command_registry);

        let result = CommandBuilder::new(
            "noactioncmd".to_string(),
            ContextFilter::new(),
            registry_arc,
        )
        .description("This command has no action")
        .register();

        assert!(result.is_err());
        if let Err(FrameworkError::Command(msg)) = result {
            assert_eq!(msg, "指令 'noactioncmd' 没有定义 action");
        } else {
            panic!("Expected FrameworkError::Command");
        }
    }

    #[tokio::test]
    async fn test_command_context_filter_match() {
        let mut registry = CommandRegistry::new();
        let executed_flag = Arc::new(Mutex::new(false));
        let flag_clone = Arc::clone(&executed_flag);

        let cmd_filter = ContextFilter::new()
            .user("user123")
            .platform("test_platform");
        let cmd = Command {
            name: "filteredcmd".to_string(),
            aliases: vec![],
            description: None,
            filter: cmd_filter,
            action: Box::new(move |_session, _args| {
                let mut flag = flag_clone.lock().unwrap();
                *flag = true;
                Box::pin(async { Ok(()) })
            }),
        };
        registry.register(cmd).unwrap();

        let session_match = create_test_session(
            "test_platform",
            "user123",
            "guild1",
            "channel1",
            false,
            "/filteredcmd",
            vec![],
        );
        let prefixes = ["/"];
        let executed = registry
            .parse_and_execute(Arc::clone(&session_match), "/filteredcmd", &prefixes)
            .await
            .unwrap();
        assert!(executed);
        assert!(*executed_flag.lock().unwrap());

        *executed_flag.lock().unwrap() = false;

        let session_no_match_user = create_test_session(
            "test_platform",
            "user456",
            "guild1",
            "channel1",
            false,
            "/filteredcmd",
            vec![],
        );
        let executed = registry
            .parse_and_execute(session_no_match_user, "/filteredcmd", &prefixes)
            .await
            .unwrap();
        assert!(!executed);
        assert!(!*executed_flag.lock().unwrap());

        let session_no_match_platform = create_test_session(
            "other_platform",
            "user123",
            "guild1",
            "channel1",
            false,
            "/filteredcmd",
            vec![],
        );
        let executed = registry
            .parse_and_execute(session_no_match_platform, "/filteredcmd", &prefixes)
            .await
            .unwrap();
        assert!(!executed);
        assert!(!*executed_flag.lock().unwrap());
    }
}