@@ -18,15 +18,14 @@ use crossterm::{
1818 cursor, execute,
1919 terminal:: { Clear , ClearType } ,
2020} ;
21- use fishpi_rust:: { ChatRoomDataContent , ChatRoomMessage , ChatRoomUser , GestureType , RedPacketType } ;
21+ use fishpi_rust:: { ChatRoomDataContent , ChatRoomMessage , GestureType , RedPacketType } ;
2222use lru:: LruCache ;
2323use std:: borrow:: Cow ;
2424use std:: io:: { self , Write } ;
2525use std:: sync:: { Arc , Mutex } ;
2626
2727pub struct ChatroomCommand {
2828 context : CommandContext ,
29- online_users : Arc < Mutex < Vec < ChatRoomUser > > > ,
3029 redpacket_handler : RedpacketCommand ,
3130 filter_handler : FilterCommand ,
3231 message_cache : Arc < Mutex < LruCache < String , ChatRoomMessage > > > ,
@@ -36,7 +35,6 @@ impl ChatroomCommand {
3635 pub fn new ( context : CommandContext ) -> Self {
3736 Self {
3837 context : context. clone ( ) ,
39- online_users : Arc :: new ( Mutex :: new ( vec ! [ ] ) ) ,
4038 redpacket_handler : RedpacketCommand :: new ( context) ,
4139 filter_handler : FilterCommand :: new ( ) ,
4240 message_cache : Arc :: new ( Mutex :: new ( LruCache :: new (
@@ -89,10 +87,7 @@ impl Command for ChatroomCommand {
8987
9088impl ChatroomCommand {
9189 async fn chatroom_loop ( & self ) -> Result < ( ) > {
92- let completer = CommandCompleter {
93- commands : vec ! [ ] ,
94- users : Arc :: clone ( & self . online_users ) ,
95- } ;
90+ let completer = CommandCompleter { commands : vec ! [ ] } ;
9691 let mut input_handler = CrosstermInputHandler :: with_completer ( completer) ;
9792 input_handler. set_commands ( vec ! [
9893 CommandItem {
@@ -197,7 +192,10 @@ impl ChatroomCommand {
197192 let stats = crate :: utils:: GESTURE_STATS . lock ( ) . unwrap ( ) ;
198193 let total: u64 = stats. iter ( ) . sum ( ) ;
199194 if total == 0 {
200- println ! ( "石头: {}, 剪刀: {}, 布: {},总数: 0" , stats[ 0 ] , stats[ 1 ] , stats[ 2 ] ) ;
195+ println ! (
196+ "石头: {}, 剪刀: {}, 布: {},总数: 0" ,
197+ stats[ 0 ] , stats[ 1 ] , stats[ 2 ]
198+ ) ;
201199 } else {
202200 let rock_pct = stats[ 0 ] as f64 / total as f64 * 100.0 ;
203201 let scissors_pct = stats[ 1 ] as f64 / total as f64 * 100.0 ;
@@ -335,7 +333,6 @@ impl ChatroomCommand {
335333 }
336334
337335 async fn register_message_handler ( & self ) -> Result < ( ) > {
338- let online_users = Arc :: clone ( & self . online_users ) ;
339336 let auth = Arc :: clone ( & self . context . auth ) ;
340337 let client = Arc :: clone ( & self . context . client ) ;
341338 let redpacket_cache = Arc :: clone ( & self . redpacket_handler . redpacket_cache ) ;
@@ -348,7 +345,6 @@ impl ChatroomCommand {
348345 . client
349346 . chatroom
350347 . add_listener ( move |data| {
351- let online_users = Arc :: clone ( & online_users) ;
352348 let auth = Arc :: clone ( & auth) ;
353349 let client = Arc :: clone ( & client) ;
354350 let redpacket_cache = Arc :: clone ( & redpacket_cache) ;
@@ -491,11 +487,7 @@ impl ChatroomCommand {
491487 ChatRoomDataContent :: Custom ( custom) => {
492488 println ! ( "\r [{}]" , custom. cyan( ) ) ;
493489 }
494- ChatRoomDataContent :: OnlineUsers ( online_user, ..) => {
495- if let Ok ( mut users) = online_users. lock ( ) {
496- * users = online_user;
497- }
498- }
490+ ChatRoomDataContent :: OnlineUsers ( ..) => { }
499491 ChatRoomDataContent :: Discuss ( topic) => {
500492 println ! ( "\r {}: {}" , "💬 话题变更" . yellow( ) . bold( ) , topic. yellow( ) ) ;
501493 }
0 commit comments