3131
3232#include " core_channel.h"
3333
34- enum
35- {
36- // From RFC 1459.
37- RPL_NAMREPLY = 353 ,
38- RPL_ENDOFNAMES = 366 ,
39- };
40-
4134CommandNames::CommandNames (Module* parent)
4235 : SplitCommand(parent, " NAMES" )
4336 , secretmode(parent, " secret" )
@@ -50,18 +43,19 @@ CommandNames::CommandNames(Module* parent)
5043
5144CmdResult CommandNames::HandleLocal (LocalUser* user, const Params& parameters)
5245{
53- Channel* c;
54-
5546 if (parameters.empty ())
5647 {
5748 user->WriteNumeric (RPL_ENDOFNAMES , ' *' , " End of /NAMES list." );
5849 return CmdResult::SUCCESS ;
5950 }
6051
6152 if (CommandParser::LoopCall (user, this , parameters, 0 ))
53+ {
54+ user->WriteNumeric (RPL_ENDOFNAMES , parameters[0 ], " End of /NAMES list." );
6255 return CmdResult::SUCCESS ;
56+ }
6357
64- c = ServerInstance->Channels .Find (parameters[0 ]);
58+ auto * c = ServerInstance->Channels .Find (parameters[0 ]);
6559 if (c)
6660 {
6761 // Show the NAMES list if one of the following is true:
@@ -72,14 +66,12 @@ CmdResult CommandNames::HandleLocal(LocalUser* user, const Params& parameters)
7266 // If the user is inside the channel or has privs, instruct SendNames() to show invisible (+i) members
7367 bool show_invisible = ((c->HasUser (user)) || (user->HasPrivPermission (" channels/auspex" )));
7468 if ((show_invisible) || (!c->IsModeSet (secretmode)))
75- {
7669 SendNames (user, c, show_invisible);
77- return CmdResult::SUCCESS ;
78- }
7970 }
8071
81- user->WriteNumeric (RPL_ENDOFNAMES , parameters[0 ], " End of /NAMES list." );
82- return CmdResult::FAILURE ;
72+ if (!this ->loopcall )
73+ user->WriteNumeric (RPL_ENDOFNAMES , parameters[0 ], " End of /NAMES list." );
74+ return c ? CmdResult::SUCCESS : CmdResult::FAILURE ;
8375}
8476
8577void CommandNames::SendNames (LocalUser* user, Channel* chan, bool show_invisible)
@@ -118,5 +110,4 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible
118110 }
119111
120112 reply.Flush ();
121- user->WriteNumeric (RPL_ENDOFNAMES , chan->name , " End of /NAMES list." );
122113}
0 commit comments