@@ -57,31 +57,34 @@ impl<'a, I: InterfaceOut> SimpleInterfaceIn<'a, I> {
57
57
}
58
58
}
59
59
60
+ impl < ' a , I : InterfaceOut > SimpleInterfaceIn < ' a , I > {
61
+ pub fn process_player_message ( & mut self , msg : PlayerMessage ) {
62
+ println ! ( "processing player message {msg:?}" ) ;
63
+ if let Some ( cmd) = msg. into_cmd ( ) {
64
+ let name = cmd. command ;
65
+ let args_str: Vec < & str > = cmd. args . iter ( ) . map ( String :: as_str) . collect ( ) ;
66
+ if let Err ( err) = process_command (
67
+ & name,
68
+ & args_str,
69
+ self . local ,
70
+ self . global ,
71
+ self . actions ,
72
+ self . out ,
73
+ ) {
74
+ println ! ( "could not process command. Reason: {err:?}" ) ;
75
+ }
76
+ }
77
+ }
78
+ }
79
+
60
80
impl < ' a , I : InterfaceOut > InterfaceIn for SimpleInterfaceIn < ' a , I > {
61
81
fn on_chat ( & mut self , message : Chat ) {
62
82
println ! ( "{}" , message. clone( ) . colorize( ) ) ;
63
83
64
- let mut process = |msg : PlayerMessage | {
65
- if let Some ( cmd) = msg. into_cmd ( ) {
66
- let name = cmd. command ;
67
- let args_str: Vec < & str > = cmd. args . iter ( ) . map ( String :: as_str) . collect ( ) ;
68
- if let Err ( err) = process_command (
69
- & name,
70
- & args_str,
71
- self . local ,
72
- self . global ,
73
- self . actions ,
74
- self . out ,
75
- ) {
76
- println ! ( "could not process command. Reason: {err:?}" ) ;
77
- }
78
- }
79
- } ;
80
-
81
84
if let Some ( msg) = message. player_message ( ) {
82
- process ( msg) ;
85
+ self . process_player_message ( msg) ;
83
86
} else if let Some ( msg) = message. player_dm ( ) {
84
- process ( msg) ;
87
+ self . process_player_message ( msg) ;
85
88
}
86
89
}
87
90
0 commit comments