[srvx-commits] CVS: services/src nickserv.help.m4,1.7,1.8 nickserv.h,1.32,1.33 nickserv.c,1.174,1.17
Brought to you by:
entrope
|
From: Entrope <en...@us...> - 2002-07-04 02:47:33
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv9418/src
Modified Files:
nickserv.help.m4 nickserv.h nickserv.c global.h global.c
Log Message:
add opt-in/opt-out "announcements" setting per-handle for community announcements
Index: nickserv.help.m4
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.help.m4,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -r1.7 -r1.8
*** nickserv.help.m4 2 Jul 2002 00:52:23 -0000 1.7
--- nickserv.help.m4 4 Jul 2002 02:47:30 -0000 1.8
***************
*** 200,219 ****
"OSET" ("$bOSET$b",
"/msg $N OSET <nick|*account> [<setting> <value>]",
! "Changes an account's settings for srvx. Settings are:",
! "$bINFO$b: Sets infoline for $b$N$b which can be viewed with $baccountinfo$b.",
! "$bWIDTH$b: Sets the width srvx will wrap normal text to. (Use 0 for the default.)",
! "$bTABLEWIDTH$b: Sets the width srvx will wrap table text to. (Use 0 for the default.)",
! "$bCOLOR$b: Sets whether srvx will use $bbold$b in text it sends to that account.",
! "$bSTYLE$b: Sets what style srvx will use for text it sends. $bSTYLE$b can be either $bDef$b or $bZoot$b (default).",
"$bPASSWORD$b: Sets user's password.",
"$bFLAGS$b: Changes account flags for user.",
"$bLEVEL$b: Sets $O access level.",
"$bEPITHET$b: The description $C shows for the user's access.",
- ifdef({/services/nickserv/email_enabled},
- { "$bEMAIL$b: Sets (or changes) your email address.",})
"You may use *Account instead of Nick as the name argument; the * makes $N use the name of an account directly (useful if the user is not online).",
ifdef({/services/nickserv/disable_nicks},
! { "$uSee Also:$u accountinfo, userinfo, account flags"},
! { "$uSee Also:$u accountinfo, nickinfo, userinfo, account flags"}));
"PASS" ("$bPASS$b",
"/msg $n PASS <oldpass> <newpass>",
--- 200,212 ----
"OSET" ("$bOSET$b",
"/msg $N OSET <nick|*account> [<setting> <value>]",
! "Changes an account's settings for srvx. In addition to the normal $bset$b settings, you may set:",
"$bPASSWORD$b: Sets user's password.",
"$bFLAGS$b: Changes account flags for user.",
"$bLEVEL$b: Sets $O access level.",
"$bEPITHET$b: The description $C shows for the user's access.",
"You may use *Account instead of Nick as the name argument; the * makes $N use the name of an account directly (useful if the user is not online).",
ifdef({/services/nickserv/disable_nicks},
! { "$uSee Also:$u accountinfo, account flags, set, userinfo"},
! { "$uSee Also:$u accountinfo, account flags, nickinfo, set, userinfo"}));
"PASS" ("$bPASS$b",
"/msg $n PASS <oldpass> <newpass>",
***************
*** 241,252 ****
"/msg $N SET [<setting> [value]]",
"Changes your account settings for srvx. Settings are:",
! "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).",
! "$bWIDTH$b: The width you want srvx to wrap text it sends you.",
"$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.",
- "$bPRIVMSG$b: If set, $b$N$b and $b$C$b will send text to you using PRIVMSGs rather than NOTICEs.",
- "$bSTYLE$b: The style you want srvx to use for channel userlists it sends you. $bSTYLE$b can be either $bDef$b or $bZoot$b (default).",
ifdef({/services/nickserv/email_enabled},
{ "$bEMAIL$b: Sets (or changes) your email address.",})
! " ",
"$bset$b with no arguments returns your current settings.",
ifdef({/services/nickserv/disable_nicks},
--- 234,246 ----
"/msg $N SET [<setting> [value]]",
"Changes your account settings for srvx. Settings are:",
! "$bANNOUNCEMENTS$b: Indicates whether you wish to receive community announcements via the $G service.",
"$bCOLOR$b: If set, $b$N$b and $b$C$b will use $bbold$b and $uunderlines$u in text they send you.",
ifdef({/services/nickserv/email_enabled},
{ "$bEMAIL$b: Sets (or changes) your email address.",})
! "$bINFO$b: Your infoline for $b$N$b (which can be viewed with the $baccountinfo$b command).",
! "$bPRIVMSG$b: If set, $b$N$b and $b$C$b will send text to you using PRIVMSGs rather than NOTICEs.",
! "$bSTYLE$b: The style you want srvx to use for channel userlists it sends you. $bSTYLE$b can be either $bDef$b or $bZoot$b (default).",
! "$bTABLEWIDTH$b: Sets the width for wrapping table-formatted text. (Use 0 for the default.)",
! "$bWIDTH$b: The width you want srvx to wrap text it sends you. (Use 0 for the default.)",
"$bset$b with no arguments returns your current settings.",
ifdef({/services/nickserv/disable_nicks},
Index: nickserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** nickserv.h 2 Jul 2002 01:25:02 -0000 1.32
--- nickserv.h 4 Jul 2002 02:47:30 -0000 1.33
***************
*** 91,94 ****
--- 91,95 ----
char last_authed_host[USERLEN+HOSTLEN+2];
char userlist_style;
+ char announcements;
};
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.174
retrieving revision 1.175
diff -C2 -r1.174 -r1.175
*** nickserv.c 3 Jul 2002 15:44:23 -0000 1.174
--- nickserv.c 4 Jul 2002 02:47:30 -0000 1.175
***************
*** 112,115 ****
--- 112,116 ----
#define KEY_EPITHET "epithet"
#define KEY_TABLE_WIDTH "table_width"
+ #define KEY_ANNOUNCEMENTS "announcements"
#define NSMSG_RIGHT_NOW "Right now!"
***************
*** 234,240 ****
#define NSMSG_SETTING_LIST "$b$N account settings:$b"
#define NSMSG_INVALID_OPTION "$b%s$b is an invalid account setting."
! #define NSMSG_STR_SETTING "$b%13s $b%s"
! #define NSMSG_NUM_SETTING "$b%13s $b%d"
#define NICKSERV_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
--- 235,242 ----
#define NSMSG_SETTING_LIST "$b$N account settings:$b"
#define NSMSG_INVALID_OPTION "$b%s$b is an invalid account setting."
+ #define NSMSG_INVALID_ANNOUNCE "$b%s$b is an announcements value."
! #define NSMSG_STR_SETTING "$b%14s $b%s"
! #define NSMSG_NUM_SETTING "$b%14s $b%d"
#define NICKSERV_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
***************
*** 336,339 ****
--- 338,342 ----
hi = calloc(1, sizeof(*hi));
hi->userlist_style = HI_DEFAULT_STYLE;
+ hi->announcements = '?';
safestrncpy(hi->handle, handle, sizeof(hi->handle));
safestrncpy(hi->passwd, passwd, sizeof(hi->passwd));
***************
*** 1769,1773 ****
unsigned int i = 0;
char *set_display[] = {
! "INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", "STYLE", "EMAIL"};
nickserv_notice(user, NSMSG_SETTING_LIST);
--- 1772,1776 ----
unsigned int i = 0;
char *set_display[] = {
! "INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", "STYLE", "EMAIL", "ANNOUNCEMENTS"};
nickserv_notice(user, NSMSG_SETTING_LIST);
***************
*** 1942,1945 ****
--- 1945,1976 ----
}
+ static OPTION_FUNC(opt_announcements)
+ {
+ char *choice;
+
+ (void)override;
+ if (argc > 1) {
+ if (enabled_string(argv[1])) {
+ hi->announcements = 'y';
+ } else if (disabled_string(argv[1])) {
+ hi->announcements = 'n';
+ } else if (!strcmp(argv[1], "?") || !strcasecmp(argv[1], "default")) {
+ hi->announcements = '?';
+ } else {
+ nickserv_notice(user, NSMSG_INVALID_ANNOUNCE, argv[1]);
+ return 0;
+ }
+ }
+
+ switch (hi->announcements) {
+ case 'y': choice = "on"; break;
+ case 'n': choice = "off"; break;
+ case '?': choice = "default"; break;
+ default: choice = "unknown"; break;
+ }
+ nickserv_notice(user, NSMSG_STR_SETTING, "ANNOUNCEMENTS:", choice);
+ return 1;
+ }
+
static OPTION_FUNC(opt_password)
{
***************
*** 2279,2286 ****
dict_insert(obj, KEY_FLAGS, alloc_record_data_qstring(flags));
}
! /* record the user list style, cheat and reuse 'flags' */
flags[0] = hi->userlist_style;
flags[1] = 0;
dict_insert(obj, KEY_USERLIST_STYLE, alloc_record_data_qstring(flags));
/* record the infoline, if one is set */
if (hi->infoline) {
--- 2310,2323 ----
dict_insert(obj, KEY_FLAGS, alloc_record_data_qstring(flags));
}
! /* record the user list style (cheat and reuse 'flags') */
flags[0] = hi->userlist_style;
flags[1] = 0;
dict_insert(obj, KEY_USERLIST_STYLE, alloc_record_data_qstring(flags));
+ /* record the announcements options (cheat again here) */
+ if (hi->announcements != '?') {
+ flags[0] = hi->announcements;
+ flags[1] = 0;
+ dict_insert(obj, KEY_ANNOUNCEMENTS, alloc_record_data_qstring(flags));
+ }
/* record the infoline, if one is set */
if (hi->infoline) {
***************
*** 2859,2862 ****
--- 2896,2901 ----
str = database_get_data(obj, KEY_USERLIST_STYLE, RECDB_QSTRING);
hi->userlist_style = str ? str[0] : HI_STYLE_ZOOT;
+ str = database_get_data(obj, KEY_ANNOUNCEMENTS, RECDB_QSTRING);
+ hi->announcements = str ? str[0] : '?';
str = database_get_data(obj, KEY_SCREEN_WIDTH, RECDB_QSTRING);
hi->screen_width = str ? strtoul(str, NULL, 0) : 0;
***************
*** 3337,3340 ****
--- 3376,3380 ----
dict_insert(nickserv_opt_dict, "LEVEL", opt_level);
dict_insert(nickserv_opt_dict, "EPITHET", opt_epithet);
+ dict_insert(nickserv_opt_dict, "ANNOUNCEMENTS", opt_announcements);
nickserv_handle_dict = dict_new();
Index: global.h
===================================================================
RCS file: /cvsroot/srvx/services/src/global.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -r1.12 -r1.13
*** global.h 6 May 2002 23:33:12 -0000 1.12
--- global.h 4 Jul 2002 02:47:30 -0000 1.13
***************
*** 26,29 ****
--- 26,30 ----
#define MESSAGE_RECIPIENT_OPERS 0x004
#define MESSAGE_RECIPIENT_CHANNELS 0x008
+ #define MESSAGE_RECIPIENT_ANNOUNCE 0x040
#define MESSAGE_OPTION_SOURCELESS 0x010
Index: global.c
===================================================================
RCS file: /cvsroot/srvx/services/src/global.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -r1.43 -r1.44
*** global.c 26 Jun 2002 11:45:28 -0000 1.43
--- global.c 4 Jul 2002 02:47:30 -0000 1.44
***************
*** 55,58 ****
--- 55,59 ----
/* Global options */
#define KEY_DB_BACKUP_FREQ "db_backup_freq"
+ #define KEY_ANNOUNCEMENTS_DEFAULT "announcements_default"
#define KEY_NICK "nick"
***************
*** 109,112 ****
--- 110,114 ----
{
unsigned long db_backup_frequency;
+ unsigned int announcements_default : 1;
} global_conf;
***************
*** 280,283 ****
--- 282,287 ----
} else if(!strcasecmp(argv[i], "channels")) {
flags |= MESSAGE_RECIPIENT_CHANNELS;
+ } else if(!strcasecmp(argv[i], "announcement") || !strcasecmp(argv[i], "announce")) {
+ flags |= MESSAGE_RECIPIENT_ANNOUNCE;
} else {
global_notice(user, GMSG_INVALID_TARGET, argv[i]);
***************
*** 316,319 ****
--- 320,327 ----
return "staff";
}
+ else if(message->flags & MESSAGE_RECIPIENT_ANNOUNCE)
+ {
+ return "announcement";
+ }
else if(message->flags & MESSAGE_RECIPIENT_OPERS)
{
***************
*** 379,382 ****
--- 387,391 ----
struct userNode *user;
unsigned long n;
+ dict_iterator_t it;
if(message->flags & MESSAGE_RECIPIENT_CHANNELS)
***************
*** 391,394 ****
--- 400,417 ----
}
+ if(message->flags & MESSAGE_RECIPIENT_ANNOUNCE)
+ {
+ char announce;
+
+ for (it = dict_first(clients); it; it = iter_next(it)) {
+ user = iter_data(it);
+ if (user->uplink == self) continue;
+ announce = user->handle_info ? user->handle_info->announcements : '?';
+ if (announce == 'n') continue;
+ if ((announce == '?') && !global_conf.announcements_default) continue;
+ notice_target(user->nick, message);
+ }
+ }
+
if(message->flags & MESSAGE_RECIPIENT_OPERS)
{
***************
*** 477,480 ****
--- 500,505 ----
} else if(!strcasecmp(argv[1], "staff") || !strcasecmp(argv[1], "privileged")) {
target |= MESSAGE_RECIPIENT_HELPERS | MESSAGE_RECIPIENT_OPERS;
+ } else if(!strcasecmp(argv[1], "announcement") || !strcasecmp(argv[1], "announce")) {
+ target |= MESSAGE_RECIPIENT_ANNOUNCE;
} else if(!strcasecmp(argv[1], "channels")) {
target = MESSAGE_RECIPIENT_CHANNELS;
***************
*** 827,830 ****
--- 852,857 ----
str = database_get_data(conf_node, KEY_DB_BACKUP_FREQ, RECDB_QSTRING);
global_conf.db_backup_frequency = str ? ParseInterval(str) : 7200;
+ str = database_get_data(conf_node, KEY_ANNOUNCEMENTS_DEFAULT, RECDB_QSTRING);
+ global_conf.announcements_default = str ? enabled_string(str) : 1;
str = database_get_data(conf_node, KEY_NICK, RECDB_QSTRING);
|