Thread: [srvx-commits] CVS: services/src helpserv.c,1.42,1.43
Brought to you by:
entrope
|
From: Adrian D. <sai...@us...> - 2002-10-27 20:13:31
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv27472
Modified Files:
helpserv.c
Log Message:
Fix some problems with "empty no more" alerts (happened too much) and request on join (helpers got requests)
Give credit to the last helper to leave the help channel with the empty alert
Index: helpserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/helpserv.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -r1.42 -r1.43
*** helpserv.c 26 Oct 2002 16:15:15 -0000 1.42
--- helpserv.c 26 Oct 2002 16:40:55 -0000 1.43
***************
*** 198,202 ****
#define HSMSG_PAGE_IDLE_HEADER "$b%u users$b in %s $bidle at least %s$b:"
#define HSMSG_PAGE_EMPTYALERT "$b%s has no helpers present$b"
! #define HSMSG_PAGE_ONLYTRIALALERT "$b%s has no full helpers present (%d trial%s)$b"
#define HSMSG_PAGE_EMPTYNOMORE "%s has joined %s; cancelling the \"no helpers present\" alert"
--- 198,204 ----
#define HSMSG_PAGE_IDLE_HEADER "$b%u users$b in %s $bidle at least %s$b:"
#define HSMSG_PAGE_EMPTYALERT "$b%s has no helpers present$b"
! #define HSMSG_PAGE_ONLYTRIALALERT "$b%s has no full helpers present (%d trial%s present)$b"
! #define HSMSG_PAGE_FIRSTEMPTYALERT "$b%s has no helpers present because %s has left$b"
! #define HSMSG_PAGE_FIRSTONLYTRIALALERT "$b%s has no full helpers present because %s has left (%d trial%s present)$b"
#define HSMSG_PAGE_EMPTYNOMORE "%s has joined %s; cancelling the \"no helpers present\" alert"
***************
*** 408,411 ****
--- 410,415 ----
unsigned int req_on_join : 1;
+ unsigned int helpchan_empty : 1;
+
time_t registered;
char *registrar;
***************
*** 2194,2201 ****
}
! static void run_empty_interval(void *data) {
! struct helpserv_bot *hs=data;
! dict_iterator_t it;
int num_trials=0;
for (it=dict_first(hs->users); it; it=iter_next(it)) {
--- 2198,2208 ----
}
! /* Returns -1 if there's any helpers,
! * 0 if there are no helpers
! * >1 if there are trials (number of trials)
! */
! static int find_helpchan_helpers(struct helpserv_bot *hs) {
int num_trials=0;
+ dict_iterator_t it;
for (it=dict_first(hs->users); it; it=iter_next(it)) {
***************
*** 2203,2211 ****
if (find_handle_in_channel(hs->helpchan, hs_user->handle, NULL)) {
! if (hs_user->level >= HlHelper) return;
num_trials++;
}
}
if (num_trials) {
helpserv_page(PGSRC_ALERT, HSMSG_PAGE_ONLYTRIALALERT, hs->helpchan->name, num_trials, (num_trials == 1 ? "" : "s"));
--- 2210,2232 ----
if (find_handle_in_channel(hs->helpchan, hs_user->handle, NULL)) {
! if (hs_user->level >= HlHelper) {
! hs->helpchan_empty = 0;
! return -1;
! }
num_trials++;
}
}
+ hs->helpchan_empty = 1;
+ return num_trials;
+ }
+
+
+ static void run_empty_interval(void *data) {
+ struct helpserv_bot *hs=data;
+ int num_trials=find_helpchan_helpers(hs);
+
+ if (num_trials == -1) return;
+
if (num_trials) {
helpserv_page(PGSRC_ALERT, HSMSG_PAGE_ONLYTRIALALERT, hs->helpchan->name, num_trials, (num_trials == 1 ? "" : "s"));
***************
*** 3202,3207 ****
if (hs->intervals[INTERVAL_EMPTY_INTERVAL]) {
! timeq_del(0, run_empty_interval, hs, TIMEQ_IGNORE_WHEN);
! run_empty_interval(hs);
}
}
--- 3223,3236 ----
if (hs->intervals[INTERVAL_EMPTY_INTERVAL]) {
! int num_trials;
! if ((num_trials = find_helpchan_helpers(hs)) >= 0) {
! if (num_trials) {
! helpserv_page(PGSRC_ALERT, HSMSG_PAGE_FIRSTONLYTRIALALERT, hs->helpchan->name, user->nick, num_trials, (num_trials == 1 ? "" : "s"));
! } else {
! helpserv_page(PGSRC_ALERT, HSMSG_PAGE_FIRSTEMPTYALERT, hs->helpchan->name, user->nick);
! }
! timeq_del(0, run_empty_interval, hs, TIMEQ_IGNORE_WHEN);
! timeq_add(now + hs->intervals[INTERVAL_EMPTY_INTERVAL], run_empty_interval, hs);
! }
}
}
***************
*** 3371,3375 ****
struct helpserv_bot *hs=botlist->list[i];
- helpserv_message(hs, user, MSGTYPE_GREETING);
associate_requests_bybot(hs, user, 1);
--- 3400,3403 ----
***************
*** 3380,3391 ****
if (!hs_user->join_time) hs_user->join_time = now;
! if (hs_user->level >= HlHelper && hs->intervals[INTERVAL_EMPTY_INTERVAL]) {
timeq_del(0, run_empty_interval, hs, TIMEQ_IGNORE_WHEN);
helpserv_page(PGSRC_ALERT, HSMSG_PAGE_EMPTYNOMORE, user->nick, hs->helpchan->name);
}
}
}
! /* Make sure this is at the end (because of the continue) */
if (hs->req_on_join) {
struct helpserv_reqlist *reqlist;
--- 3408,3423 ----
if (!hs_user->join_time) hs_user->join_time = now;
! if (hs_user->level >= HlHelper && hs->intervals[INTERVAL_EMPTY_INTERVAL] && hs->helpchan_empty) {
! hs->helpchan_empty = 0;
timeq_del(0, run_empty_interval, hs, TIMEQ_IGNORE_WHEN);
helpserv_page(PGSRC_ALERT, HSMSG_PAGE_EMPTYNOMORE, user->nick, hs->helpchan->name);
}
+ continue; /* Don't want helpers to have request-on-join */
}
}
! helpserv_message(hs, user, MSGTYPE_GREETING);
!
! /* Make sure this is at the end (because of the continues) */
if (hs->req_on_join) {
struct helpserv_reqlist *reqlist;
|