ref: a69e8b7ae62a125b93d0aca61ccd676689c3cc9f
parent: f5cb575e6da020ae009f192aa0367affa285e189
author: mkf <mkf@cirno>
date: Tue Sep 26 22:13:59 EDT 2023
add MOTD command
--- a/ircd.c
+++ b/ircd.c
@@ -2,7 +2,7 @@
#include <libc.h>
char *password = nil; /* nil to disable server password */
-char *motd = nil; /* nil for no motd */
+char *motdtxt = nil; /* nil for no motd */
enum {
Maxclients = 48,
Maxchannels = 16,
@@ -24,6 +24,7 @@
TOPIC,
AWAY,
ERROR,
+ MOTD,
/* numericals */
RPL_WELCOME = 001,
@@ -482,6 +483,18 @@
replylist(&ch->members, r, skipme);
}
}
+
+int
+motd(Client *c)
+{
+ Reply r;
+ if(motdtxt == nil){
+ r.code = ERR_NOMOTD;
+ reply(c, &r);
+ }
+ return 1;
+}
+
void
welcome(Client *c)
{
@@ -488,10 +501,7 @@
Reply r;
r.code = RPL_WELCOME;
reply(c, &r);
- if(motd == nil){
- r.code = ERR_NOMOTD;
- reply(c, &r);
- }
+ motd(c);
}
int
@@ -1122,6 +1132,9 @@
tmp = strtok(0, " \r"); /* msg */
return away(c, tmp);
}
+ if(strcmp(cmd, "MOTD") == 0)
+ return motd(c);
+
r.code = ERR_UNKNOWNCOMMAND;
r.argv[0] = cmd;
reply(c, &r);