{"NH_NEXT_JOIN", "Please /join %s now."}, /* {ARGS: "#test-support"} */
{"NH_DELETED", "Your request ID#%d has been deleted."}, /* {ARGS: 5} */
{"NH_DELETED_STAFF", "Request deleted: #%d (%s)"}, /* {ARGS: 5, "pk910"} */
+ {"NH_REMIND_OPEN_REQUESTS_1", "There is %d unhandled request!"}, /* {ARGS: 1} */
+ {"NH_REMIND_OPEN_REQUESTS_2", "There are %d unhandled requests!"}, /* {ARGS: 4} */
+ {"NH_REQUESTS_HEADER_ID", "ID"},
+ {"NH_REQUESTS_HEADER_STATUS", "State"},
+ {"NH_REQUESTS_HEADER_NICK", "Nick"},
+ {"NH_REQUESTS_HEADER_TIME", "Time"},
+ {"NH_REQUESTS_HEADER_REQUEST", "Question"},
+ {"NH_REQUESTS_STATE_ACTIVE", "active"},
+ {"NH_REQUESTS_STATE_PENDING", "pending"},
+ {"NH_REQUESTS_STATE_ERROR", "ERROR"},
{NULL, NULL}
};
free(cache);
}
+static TIMEQ_CALLBACK(neonhelp_remind_open_requests);
+
static void neonhelp_event_privmsg_async(struct ClientSocket *client, struct UserNode *user, struct UserNode *target, char *message) {
MYSQL_RES *res;
MYSQL_ROW row, row2;
- printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
+ printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", client->clientid);
res = mysql_use();
if (!(row = mysql_fetch_row(res))) return;
//check if the user is a supporter (access in the support channel)
helpnode->user = user;
helpnode->logchan = getChanByName(row[0]);
helpnode->status = 0;
+ helpnode->announce = (row[2] && strcmp(row[3], "0") ? 1 : 0);
+ if(helpnode->announce) {
+ char nameBuf[30];
+ sprintf(nameBuf, "neonhelp_%d", client->clientid);
+ if(!timeq_name_exists(nameBuf)) {
+ int *cidptr = malloc(sizeof(int));
+ *cidptr = client->clientid;
+ timeq_add_name(nameBuf, 300, neonhelp_remind_open_requests, cidptr);
+ }
+ }
printf_mysql_query("INSERT INTO `helpserv_requests` (`botid`, `host`, `hand`, `nick`, `status`, `supporter`, `time`, `text`) VALUES ('%d', '%s@%s', '%s', '%s', '0', '-1', UNIX_TIMESTAMP(), '%s')", client->clientid, escape_string(user->ident), escape_string(user->host), ((user->flags & USERFLAG_ISAUTHED) ? escape_string(user->auth) : "*"), escape_string(user->nick), escape_string(message));
helpnode->suppid = (int) mysql_insert_id(mysql_conn);
helpnode->log = NULL;
}
}
+static TIMEQ_CALLBACK(neonhelp_remind_open_requests) {
+ int clientid = *((int*)data);
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ printf_mysql_query("SELECT `helpserv_support`, `helpserv_public`, `helpserv_intern`, `helpserv_intern_announce` FROM `helpserv_settings` WHERE `helpserv_botid` = '%d'", clientid);
+ res = mysql_use();
+ if (!(row = mysql_fetch_row(res)) || !row[2]) {
+ free(data);
+ return;
+ }
+ struct ClientSocket *client;
+ for(client = getBots(SOCKET_FLAG_READY, NULL); client; client = getBots(SOCKET_FLAG_READY, client)) {
+ if(client->clientid == clientid)
+ break;
+ }
+ if(!client) {
+ free(data);
+ return;
+ }
+ //count open requests
+ int requests = 0;
+ struct NeonHelpNode *helpnode;
+ if(client->flags & SOCKET_HAVE_HELPNODE) {
+ for(helpnode = client->botclass_helpnode; helpnode; helpnode = helpnode->next) {
+ if(helpnode->status == 0) {
+ requests++;
+ }
+ }
+ }
+ if(requests) {
+ char nameBuf[30];
+ sprintf(nameBuf, "neonhelp_%d", client->clientid);
+ if(!timeq_name_exists(nameBuf)) {
+ timeq_add_name(nameBuf, 300, neonhelp_remind_open_requests, data);
+ }
+ char replybuf[MAXLEN];
+ build_language_string(NULL, replybuf, (requests == 1 ? "NH_REMIND_OPEN_REQUESTS_1" : "NH_REMIND_OPEN_REQUESTS_2"), requests);
+ putsock(client, "PRIVMSG %s :%s", row[2], replybuf);
+ } else
+ free(data);
+}
+
static void neonhelp_event_chanmsg(struct UserNode *user, struct ChanNode *chan, char *message) {
char logline[MAXLEN];
sprintf(logline, "<%s> %s", user->nick, message);