33 lines
1,012 B
C
33 lines
1,012 B
C
|
|
#ifndef CMD_QUIT_H
|
||
|
|
#define CMD_QUIT_H
|
||
|
|
|
||
|
|
#include "zynk.h"
|
||
|
|
|
||
|
|
/*
|
||
|
|
* cmd_quit - Handle the "!quit" and "!die" shutdown commands.
|
||
|
|
*
|
||
|
|
* Requires channel op if used in a channel. Sets the global running flag
|
||
|
|
* to 0, causing the main loop to exit gracefully. Sends a farewell
|
||
|
|
* message before shutting down.
|
||
|
|
*
|
||
|
|
* Parameters:
|
||
|
|
* s - The IRC session.
|
||
|
|
* msg - The raw message text.
|
||
|
|
* reply_target - Channel or nick to reply to.
|
||
|
|
* src_nick - The nick of the user who sent the command.
|
||
|
|
* tgt - The message target (channel or nick).
|
||
|
|
*
|
||
|
|
* Returns: 1 if matched, 0 otherwise.
|
||
|
|
*/
|
||
|
|
int cmd_quit(Session *s, const char *msg, const char *reply_target, const char *src_nick, const char *tgt) {
|
||
|
|
if (strcmp(msg, "!quit") != 0 && strcmp(msg, "!die") != 0) return 0;
|
||
|
|
if (tgt[0] == '#' && !chan_is_op(tgt, src_nick)) {
|
||
|
|
irc_msg(s, reply_target, "You need op to shut me down");
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
irc_msg(s, reply_target, "pffffff, bye. :(");
|
||
|
|
running = 0;
|
||
|
|
return 1;
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif
|