* Translate interval strings to the user's language.
* Translate cookie emails and auth failure messages based on the
account's preferred language, rather than the user's preferred
language (they will not be authed, so they would get lang_C).
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-39
struct userData *user;
char delay[INTERVALLEN], reason[INTERVALLEN + 64];
- intervalString(delay, chanserv_conf.channel_expire_delay);
+ intervalString(delay, chanserv_conf.channel_expire_delay, NULL);
sprintf(reason, "Channel registration automatically expired after %s of disuse.", delay);
for(channel = channelList; channel; channel = next)
{
dnr = iter_data(it);
if(dnr->set)
- reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+ reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
else
reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
matches++;
{
dnr = iter_data(it);
if(dnr->set)
- reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+ reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
else
reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
matches++;
{
dnr = iter_data(it);
if(dnr->set)
- reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set), dnr->setter, dnr->reason);
+ reply("CSMSG_DNR_INFO_SET", dnr->chan_name, intervalString(buf, now - dnr->set, user->handle_info), dnr->setter, dnr->reason);
else
reply("CSMSG_DNR_INFO", dnr->chan_name, dnr->setter, dnr->reason);
matches++;
count++;
}
- intervalString(interval, duration);
+ intervalString(interval, duration, user->handle_info);
send_message(user, chanserv, "CSMSG_TRIMMED_BANS", count, channel->name, interval);
return 1;
}
min_access = 1;
max_access = UL_OWNER;
}
- send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration));
+ send_message(user, chanserv, "CSMSG_TRIMMED_USERS", count, min_access, max_access, channel->name, intervalString(interval, duration, user->handle_info));
return 1;
}
/* automated kickban */
}
else if(duration)
- reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration));
+ reply("CSMSG_BAN_EXTENDED", ban, intervalString(interval, duration, user->handle_info));
else
reply("CSMSG_BAN_ADDED", name, channel->name);
else if(action & ACTION_ADD_BAN)
{
if(duration)
- reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration));
+ reply("CSMSG_TIMED_BAN_ADDED", name, channel->name, intervalString(interval, duration, user->handle_info));
else
reply("CSMSG_BAN_ADDED", name, channel->name);
}
else if(!uData->seen)
ary[2] = "Never";
else
- ary[2] = intervalString(seen, now - uData->seen);
+ ary[2] = intervalString(seen, now - uData->seen, user->handle_info);
ary[2] = strdup(ary[2]);
if(IsUserSuspended(uData))
ary[3] = "Suspended";
if(!timed)
expires = "";
else if(ban->expires)
- expires = intervalString(e_buffer, ban->expires - now);
+ expires = intervalString(e_buffer, ban->expires - now, user->handle_info);
else
expires = msg_never;
if(ban->triggered)
- triggered = intervalString(t_buffer, now - ban->triggered);
+ triggered = intervalString(t_buffer, now - ban->triggered, user->handle_info);
else
triggered = msg_never;
reply("CSMSG_CHANNEL_SUSPENDED_0", suspended->suspender, suspended->reason);
break;
case 1: /* no issue time, expires in future */
- intervalString(buf1, suspended->expires-now);
+ intervalString(buf1, suspended->expires-now, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_1", suspended->suspender, buf1, suspended->reason);
break;
case 2: /* no issue time, expired */
- intervalString(buf1, now-suspended->expires);
+ intervalString(buf1, now-suspended->expires, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_2", suspended->suspender, buf1, suspended->reason);
break;
case 3: /* no issue time, revoked */
- intervalString(buf1, now-suspended->revoked);
+ intervalString(buf1, now-suspended->revoked, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_3", suspended->suspender, buf1, suspended->reason);
break;
case 4: /* issue time set, indefinite expiration */
- intervalString(buf1, now-suspended->issued);
+ intervalString(buf1, now-suspended->issued, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_4", buf1, suspended->suspender, suspended->reason);
break;
case 5: /* issue time set, expires in future */
- intervalString(buf1, now-suspended->issued);
- intervalString(buf2, suspended->expires-now);
+ intervalString(buf1, now-suspended->issued, user->handle_info);
+ intervalString(buf2, suspended->expires-now, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_5", buf1, suspended->suspender, buf2, suspended->reason);
break;
case 6: /* issue time set, expired */
- intervalString(buf1, now-suspended->issued);
- intervalString(buf2, now-suspended->expires);
+ intervalString(buf1, now-suspended->issued, user->handle_info);
+ intervalString(buf2, now-suspended->expires, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_6", buf1, suspended->suspender, buf2, suspended->reason);
break;
case 7: /* issue time set, revoked */
- intervalString(buf1, now-suspended->issued);
- intervalString(buf2, now-suspended->revoked);
+ intervalString(buf1, now-suspended->issued, user->handle_info);
+ intervalString(buf2, now-suspended->revoked, user->handle_info);
reply("CSMSG_CHANNEL_SUSPENDED_7", buf1, suspended->suspender, buf2, suspended->reason);
break;
default:
reply("CSMSG_CHANNEL_OWNER", owner->handle->handle);
reply("CSMSG_CHANNEL_USERS", cData->userCount);
reply("CSMSG_CHANNEL_BANS", cData->banCount);
- reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited));
- reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered));
+ reply("CSMSG_CHANNEL_VISITED", intervalString(buffer, now - cData->visited, user->handle_info));
+ reply("CSMSG_CHANNEL_REGISTERED", intervalString(buffer, now - cData->registered, user->handle_info));
privileged = IsStaff(user);
if(((uData && uData->access >= UL_COOWNER) || privileged) && cData->registrar)
reply("CSMSG_NETWORK_CHANNELS", registered_channels);
reply("CSMSG_NETWORK_BANS", banCount);
reply("CSMSG_CHANNEL_USERS", userCount);
- reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time));
- reply("CSMSG_BURST_LENGTH",intervalString(interval, burst_length));
+ reply("CSMSG_SERVICES_UPTIME", intervalString(interval, time(NULL) - boot_time, user->handle_info));
+ reply("CSMSG_BURST_LENGTH", intervalString(interval, burst_length, user->handle_info));
return 1;
}
if(uData->present)
reply("CSMSG_USER_PRESENT", handle->handle);
else if(uData->seen)
- reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen));
+ reply("CSMSG_USER_SEEN", handle->handle, channel->name, intervalString(seen, now - uData->seen, user->handle_info));
else
reply("CSMSG_NEVER_SEEN", handle->handle, channel->name);
limit = atoi(argv[2]);
}
- intervalString(buffer, interval);
+ intervalString(buffer, interval, user->handle_info);
reply("CSMSG_UNVISITED_HEADER", limit, buffer);
for(cData = channelList; cData && matches < limit; cData = cData->next)
if((now - cData->visited) < interval)
continue;
- intervalString(buffer, now - cData->visited);
+ intervalString(buffer, now - cData->visited, user->handle_info);
reply("CSMSG_UNVISITED_DATA", cData->channel->name, buffer);
matches++;
}
free(list->list);\
}
-/* The longest string that's likely to be produced is "10 minutes, and 10
- seconds." (27 characters) */
-#define INTERVALLEN 32
+/* The longest string that is likely to be produced in English is "10
+ * minutes, and 10 seconds" (27 characters). Other languages will
+ * vary, so there's plenty of leeway.
+ */
+#define INTERVALLEN 50
-char *intervalString2(char *output, time_t interval, int brief);
-#define intervalString(OUTPUT, INTERVAL) intervalString2((OUTPUT), (INTERVAL), 0)
+struct handle_info;
+char *intervalString(char *output, time_t interval, struct handle_info *hi);
int getipbyname(const char *name, unsigned long *ip);
int set_policer_param(const char *param, void *data, void *extra);
const char *strtab(unsigned int ii);
table.contents[nn][0] = strdup(buffer);
table.contents[nn][1] = messageType(message);
if(message->duration)
- {
- intervalString(buffer, message->posted + message->duration - now);
- }
+ intervalString(buffer, message->posted + message->duration - now, user->handle_info);
else
- {
strcpy(buffer, "Never.");
- }
table.contents[nn][2] = strdup(buffer);
table.contents[nn][3] = message->from;
length = strlen(message->message);
{ "MSG_DB_WRITE_ERROR", "Error while writing database %s." },
{ "MSG_DB_WROTE_DB", "Wrote database %s (in "FMT_TIME_T".%06lu seconds)." },
{ "MSG_DB_WROTE_ALL", "Wrote all databases (in "FMT_TIME_T".%06lu seconds)." },
+ { "MSG_AND", "and" },
+ { "MSG_0_SECONDS", "0 seconds" },
+ { "MSG_YEAR", "year" },
+ { "MSG_YEARS", "years" },
+ { "MSG_WEEK", "week" },
+ { "MSG_WEEKS", "weeks" },
+ { "MSG_DAY", "day" },
+ { "MSG_DAYS", "days" },
+ { "MSG_HOUR", "hour" },
+ { "MSG_HOURS", "hours" },
+ { "MSG_MINUTE", "minute" },
+ { "MSG_MINUTES", "minutes" },
+ { "MSG_SECOND", "second" },
+ { "MSG_SECONDS", "seconds" },
{ NULL, NULL }
};
sprintf(lbuf[0], fmt, req->id);
}
if (req != hs->unhandled) {
- intervalString(unh, now - hs->unhandled->opened);
+ intervalString(unh, now - hs->unhandled->opened, user->handle_info);
fmt = user_find_message(user, "HSMSG_REQ_UNHANDLED_TIME");
sprintf(lbuf[1], fmt, unh);
} else {
char buf[MAX_LINE_SIZE], updatestr[INTERVALLEN], timestr[MAX_LINE_SIZE];
strftime(timestr, MAX_LINE_SIZE, HSFMT_TIME, localtime(&req->opened));
- intervalString(updatestr, now - req->updated);
+ intervalString(updatestr, now - req->updated, user->handle_info);
if (req->helper && (hs->notify >= NOTIFY_USER))
if (user->handle_info)
helpserv_notify(req->helper, "HSMSG_PAGE_UPD_REQUEST_AUTHED", req->id, user->nick, user->handle_info->handle, timestr, updatestr);
pos = count;
}
assert(pos >= 0);
- intervalString(buf, now - req->hs->unhandled->opened);
+ intervalString(buf, now - req->hs->unhandled->opened, req->user->handle_info);
helpserv_user_reply("HSMSG_WAIT_STATUS", pos+1, count, buf);
}
}
tbl.contents[line][1] = strdup(username);
tbl.contents[line][2] = req->helper ? req->helper->handle->handle : "(Unassigned)";
- intervalString(opentime, now - req->opened);
+ intervalString(opentime, now - req->opened, user->handle_info);
tbl.contents[line][3] = strdup(opentime);
tbl.contents[line][4] = ((req->user || req->handle->users) ? "Online" : "Offline");
}
else
helpserv_notice(user, "HSMSG_REQ_INFO_2e");
strftime(buf, MAX_LINE_SIZE, HSFMT_TIME, localtime(&req->opened));
- intervalString(buf2, now - req->opened);
+ intervalString(buf2, now - req->opened, user->handle_info);
helpserv_notice(user, "HSMSG_REQ_INFO_3", buf, buf2);
helpserv_notice(user, "HSMSG_REQ_INFO_4");
for (nn=0; nn < req->text->used; nn++)
tbl.contents[i][1] = bot->helpchan->name;
tbl.contents[i][2] = owner ? owner->handle->handle : "None";
tbl.contents[i][3] = alloca(INTERVALLEN);
- intervalString((char*)tbl.contents[i][3], now - bot->last_active);
+ intervalString((char*)tbl.contents[i][3], now - bot->last_active, user->handle_info);
}
table_send((from_opserv ? opserv : hs->helpserv), user->nick, 0, NULL, tbl);
if (reqlist.used) {
char strwhinedelay[INTERVALLEN];
- intervalString(strwhinedelay, (time_t)hs->intervals[INTERVAL_WHINE_DELAY]);
+ intervalString(strwhinedelay, (time_t)hs->intervals[INTERVAL_WHINE_DELAY], NULL);
#if ANNOYING_ALERT_PAGES
tbl.length = reqlist.used + 1;
tbl.width = 4;
tbl.contents[i][0] = strdup(reqid);
tbl.contents[i][1] = unh->user ? unh->user->nick : "Not online";
tbl.contents[i][2] = unh->handle ? unh->handle->handle : "Not authed";
- intervalString(unh_time, now - unh->opened);
+ intervalString(unh_time, now - unh->opened, NULL);
tbl.contents[i][3] = strdup(unh_time);
}
}
tbl.contents[i][2] = strdup(reqid);
- intervalString(idle_time, now - mn->idle_since);
+ intervalString(idle_time, now - mn->idle_since, NULL);
tbl.contents[i][3] = strdup(idle_time);
}
- intervalString(stridledelay, (time_t)hs->intervals[INTERVAL_IDLE_DELAY]);
+ intervalString(stridledelay, (time_t)hs->intervals[INTERVAL_IDLE_DELAY], NULL);
helpserv_page(PGSRC_STATUS, "HSMSG_PAGE_IDLE_HEADER", mode_list.used, hs->helpchan->name, stridledelay);
table_send(hs->helpserv, hs->page_targets[PGSRC_STATUS]->name, 0, page_types[hs->page_types[PGSRC_STATUS]].func, tbl);
return 0;
}
if (new_int && new_int < min) {
- intervalString(buf, min);
+ intervalString(buf, min, user->handle_info);
helpserv_notice(user, "HSMSG_INVALID_INTERVAL", user_find_message(user, interval_types[idx].print_name), buf);
return 0;
}
changed = 1;
}
if (hs->intervals[idx]) {
- intervalString(buf, hs->intervals[idx]);
+ intervalString(buf, hs->intervals[idx], user->handle_info);
helpserv_notice(user, interval_types[idx].print_name, buf);
} else
helpserv_notice(user, interval_types[idx].print_name, user_find_message(user, "HSMSG_0_DISABLED"));
return 1;
}
- intervalString(interval, memoserv_conf.message_expiry);
+ intervalString(interval, memoserv_conf.message_expiry, user->handle_info);
reply("MSMSG_EXPIRY", interval, memoserv_conf.message_expiry);
return 1;
}
reply("PCMSG_NOT_CACHED", hostname);
return 0;
}
- intervalString(elapse_buf, now - sci->last_touched);
+ intervalString(elapse_buf, now - sci->last_touched, user->handle_info);
switch (sci->decision) {
case CHECKING: msg = "PCMSG_STATUS_CHECKING"; break;
case ACCEPT: msg = "PCMSG_STATUS_ACCEPTED"; break;
{ "NSMSG_NICK_NOT_REGISTERED", "Nick $b%s$b has not been registered to any account." },
{ "NSMSG_HANDLE_NOT_FOUND", "Could not find your account -- did you register yet?" },
{ "NSMSG_ALREADY_AUTHED", "You are already authed to account $b%s$b; you must reconnect to auth to a different account." },
- { "NSMSG_USE_AUTHCOOKIE", "Your hostmask is not valid for account $b%s$b. Please use the $bauthcookie$b command to grant yourself access. (/msg $S authcookie %s)" },
+ { "NSMSG_USE_AUTHCOOKIE", "Your hostmask is not valid for account $b%1$s$b. Please use the $bauthcookie$b command to grant yourself access. (/msg $S authcookie %1$s)" },
{ "NSMSG_HOSTMASK_INVALID", "Your hostmask is not valid for account $b%s$b." },
{ "NSMSG_USER_IS_SERVICE", "$b%s$b is a network service; you can only use that command on real users." },
{ "NSMSG_USER_PREV_AUTH", "$b%s$b is already authenticated." },
case ACTIVATION:
hi->passwd[0] = 0; /* invalidate password */
send_message(user, nickserv, "NSMSG_USE_COOKIE_REGISTER");
- fmt = user_find_message(user, "NSEMAIL_ACTIVATION_SUBJECT");
+ fmt = handle_find_message(hi, "NSEMAIL_ACTIVATION_SUBJECT");
snprintf(subject, sizeof(subject), fmt, netname);
- fmt = user_find_message(user, "NSEMAIL_ACTIVATION_BODY");
+ fmt = handle_find_message(hi, "NSEMAIL_ACTIVATION_BODY");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
first_time = 1;
break;
case PASSWORD_CHANGE:
send_message(user, nickserv, "NSMSG_USE_COOKIE_RESETPASS");
- fmt = user_find_message(user, "NSEMAIL_PASSWORD_CHANGE_SUBJECT");
+ fmt = handle_find_message(hi, "NSEMAIL_PASSWORD_CHANGE_SUBJECT");
snprintf(subject, sizeof(subject), fmt, netname);
- fmt = user_find_message(user, "NSEMAIL_PASSWORD_CHANGE_BODY");
+ fmt = handle_find_message(hi, "NSEMAIL_PASSWORD_CHANGE_BODY");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
break;
case EMAIL_CHANGE:
hi->email_addr = cookie->data;
if (misc) {
send_message(user, nickserv, "NSMSG_USE_COOKIE_EMAIL_2");
- fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_SUBJECT");
+ fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_SUBJECT");
snprintf(subject, sizeof(subject), fmt, netname);
- fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_BODY_NEW");
+ fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_BODY_NEW");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie+COOKIELEN/2, nickserv->nick, self->name, hi->handle, COOKIELEN/2);
sendmail(nickserv, hi, subject, body, 1);
- fmt = user_find_message(user, "NSEMAIL_EMAIL_CHANGE_BODY_OLD");
+ fmt = handle_find_message(hi, "NSEMAIL_EMAIL_CHANGE_BODY_OLD");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle, COOKIELEN/2, hi->email_addr);
} else {
send_message(user, nickserv, "NSMSG_USE_COOKIE_EMAIL_1");
- fmt = user_find_message(user, "NSEMAIL_EMAIL_VERIFY_SUBJECT");
+ fmt = handle_find_message(hi, "NSEMAIL_EMAIL_VERIFY_SUBJECT");
snprintf(subject, sizeof(subject), fmt, netname);
- fmt = user_find_message(user, "NSEMAIL_EMAIL_VERIFY_BODY");
+ fmt = handle_find_message(hi, "NSEMAIL_EMAIL_VERIFY_BODY");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
sendmail(nickserv, hi, subject, body, 1);
subject[0] = 0;
hi->email_addr = misc;
break;
case ALLOWAUTH:
- fmt = user_find_message(user, "NSEMAIL_ALLOWAUTH_SUBJECT");
+ fmt = handle_find_message(hi, "NSEMAIL_ALLOWAUTH_SUBJECT");
snprintf(subject, sizeof(subject), fmt, netname);
- fmt = user_find_message(user, "NSEMAIL_ALLOWAUTH_BODY");
+ fmt = handle_find_message(hi, "NSEMAIL_ALLOWAUTH_BODY");
snprintf(body, sizeof(body), fmt, netname, cookie->cookie, nickserv->nick, self->name, hi->handle);
send_message(user, nickserv, "NSMSG_USE_COOKIE_AUTH");
break;
reply("NSMSG_HANDLEINFO_REGGED", ctime(&hi->registered));
if (!hi->users) {
- intervalString(buff, now - hi->lastseen);
+ intervalString(buff, now - hi->lastseen, user->handle_info);
reply("NSMSG_HANDLEINFO_LASTSEEN", buff);
} else {
reply("NSMSG_HANDLEINFO_LASTSEEN_NOW");
reply("NSMSG_HANDLE_NOT_FOUND");
return 0;
}
+ /* Responses from here on look up the language used by the handle they asked about. */
passwd = argv[pw_arg];
if (!valid_user_for(user, hi)) {
if (hi->email_addr && nickserv_conf.email_enabled)
- reply("NSMSG_USE_AUTHCOOKIE", hi->handle, hi->handle);
+ send_message_type(4, user, cmd->parent->bot,
+ handle_find_message(hi, "NSMSG_USE_AUTHCOOKIE"),
+ hi->handle);
else
- reply("NSMSG_HOSTMASK_INVALID", hi->handle);
+ send_message_type(4, user, cmd->parent->bot,
+ handle_find_message(hi, "NSMSG_HOSTMASK_INVALID"),
+ hi->handle);
argv[pw_arg] = "BADMASK";
return 1;
}
if (!checkpass(passwd, hi->passwd)) {
unsigned int n;
- reply("NSMSG_PASSWORD_INVALID");
+ send_message_type(4, user, cmd->parent->bot,
+ handle_find_message(hi, "NSMSG_PASSWORD_INVALID"));
argv[pw_arg] = "BADPASS";
for (n=0; n<failpw_func_used; n++) failpw_func_list[n](user, hi);
if (nickserv_conf.autogag_enabled) {
return 1;
}
if (HANDLE_FLAGGED(hi, SUSPENDED)) {
- reply("NSMSG_HANDLE_SUSPENDED");
+ send_message_type(4, user, cmd->parent->bot,
+ handle_find_message(hi, "NSMSG_HANDLE_SUSPENDED"));
argv[pw_arg] = "SUSPENDED";
return 1;
}
maxlogins = hi->maxlogins ? hi->maxlogins : nickserv_conf.default_maxlogins;
for (used = 0, other = hi->users; other; other = other->next_authed) {
if (++used >= maxlogins) {
- reply("NSMSG_MAX_LOGINS", maxlogins);
+ send_message_type(4, user, cmd->parent->bot,
+ handle_find_message(hi, "NSMSG_MAX_LOGINS"),
+ maxlogins);
argv[pw_arg] = "MAXLOGINS";
return 1;
}
}
+ set_user_handle_info(user, hi, 1);
if (nickserv_conf.email_required && !hi->email_addr)
reply("NSMSG_PLEASE_SET_EMAIL");
if (!is_secure_password(hi->handle, passwd, NULL))
reply("NSMSG_WEAK_PASSWORD");
if (hi->passwd[0] != '$')
cryptpass(passwd, hi->passwd);
-
reply("NSMSG_AUTH_SUCCESS");
argv[pw_arg] = "****";
- set_user_handle_info(user, hi, 1);
return 1;
}
#endif
reply("OSMSG_WHOIS_SERVER", target->uplink->name);
reply("OSMSG_WHOIS_ACCOUNT", (target->handle_info ? target->handle_info->handle : "Not authenticated"));
- intervalString(buffer, now - target->timestamp);
+ intervalString(buffer, now - target->timestamp, user->handle_info);
reply("OSMSG_WHOIS_NICK_AGE", buffer);
if (target->channels.used <= MAX_CHANNELS_WHOIS)
opserv_ison(user, target, "OSMSG_WHOIS_CHANNELS");
#endif
tbl.contents[nn][1] = buffer;
ofs = strlen(buffer) + 1;
- intervalString(buffer + ofs, now - server->link);
- if (server->self_burst) strcat(buffer + ofs, " Bursting");
+ intervalString(buffer + ofs, now - server->link, user->handle_info);
+ if (server->self_burst)
+ strcat(buffer + ofs, " Bursting");
tbl.contents[nn][2] = buffer + ofs;
nn++;
}
th = dict_find(opserv_trusted_hosts, argv[1], NULL);
if (th) {
if (th->issued)
- intervalString(issued, now - th->issued);
+ intervalString(issued, now - th->issued, user->handle_info);
if (th->expires)
- intervalString(length, th->expires - now);
+ intervalString(length, th->expires - now, user->handle_info);
if (th->limit)
sprintf(limit, "limit %lu", th->limit);
reply("OSMSG_HOST_IS_TRUSTED",
for (it = dict_first(opserv_trusted_hosts); it; it = iter_next(it)) {
th = iter_data(it);
if (th->issued)
- intervalString(issued, now - th->issued);
+ intervalString(issued, now - th->issued, user->handle_info);
if (th->expires)
- intervalString(length, th->expires - now);
+ intervalString(length, th->expires - now, user->handle_info);
if (th->limit)
sprintf(limit, "limit %lu", th->limit);
reply("OSMSG_HOST_IS_TRUSTED", iter_key(it),
clocks_per_sec = CLOCKS_PER_SEC;
}
}
- intervalString(uptime, time(NULL)-boot_time);
+ intervalString(uptime, time(NULL)-boot_time, user->handle_info);
times(&buf);
reply("OSMSG_UPTIME_STATS",
uptime, lines_processed,
table.contents[0][3] = "Reason";
for (nn=1, gag=gagList; gag; nn++, gag=gag->next) {
char expstr[INTERVALLEN];
- if (gag->expires) intervalString(expstr, gag->expires - now);
- else strcpy(expstr, "Never");
+ if (gag->expires)
+ intervalString(expstr, gag->expires - now, user->handle_info);
+ else
+ strcpy(expstr, "Never");
table.contents[nn] = calloc(table.width, sizeof(char*));
table.contents[nn][0] = gag->mask;
table.contents[nn][1] = gag->owner;
tbl.contents[ii][0] = db->name;
tbl.contents[ii][1] = db->mondo_section ? db->mondo_section : db->filename;
if (db->write_interval) {
- intervalString(buf, db->write_interval);
+ intervalString(buf, db->write_interval, user->handle_info);
} else {
strcpy(buf, "Never");
}
tbl.contents[ii][2] = buf;
if (db->last_write) {
- intervalString(buf+INTERVALLEN, now - db->last_write);
- intervalString(buf+INTERVALLEN*2, db->last_write_duration);
+ intervalString(buf+INTERVALLEN, now - db->last_write, user->handle_info);
+ intervalString(buf+INTERVALLEN*2, db->last_write_duration, user->handle_info);
} else {
strcpy(buf+INTERVALLEN, "Never");
strcpy(buf+INTERVALLEN*2, "Never");
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
+#include "helpfile.h"
#include "log.h"
#include "nickserv.h"
#include "recdb.h"
}
char *
-intervalString2(char *output, time_t interval, int brief)
+intervalString(char *output, time_t interval, struct handle_info *hi)
{
static const struct {
- const char *name;
+ const char *msg_single;
+ const char *msg_plural;
long length;
} unit[] = {
- { "year", 365 * 24 * 60 * 60 },
- { "week", 7 * 24 * 60 * 60 },
- { "day", 24 * 60 * 60 },
- { "hour", 60 * 60 },
- { "minute", 60 },
- { "second", 1 }
+ { "MSG_YEAR", "MSG_YEARS", 365 * 24 * 60 * 60 },
+ { "MSG_WEEK", "MSG_WEEKS", 7 * 24 * 60 * 60 },
+ { "MSG_DAY", "MSG_DAYS", 24 * 60 * 60 },
+ { "MSG_HOUR", "MSG_HOURS", 60 * 60 },
+ { "MSG_MINUTE", "MSG_MINUTES", 60 },
+ { "MSG_SECOND", "MSG_SECONDS", 1 }
};
+ struct language *lang;
+ const char *msg;
unsigned int type, words, pos, count;
+ lang = hi ? hi->language : lang_C;
if(!interval)
{
- strcpy(output, brief ? "0s" : "0 seconds");
- return output;
+ msg = language_find_message(lang, "MSG_0_SECONDS");
+ return strcpy(output, msg);
}
for (type = 0, words = pos = 0;
count = interval / unit[type].length;
interval = interval % unit[type].length;
- if (brief)
- pos += sprintf(output + pos, "%d%c", count, unit[type].name[0]);
- else if (words == 1)
- pos += sprintf(output + pos, " and %d %s", count, unit[type].name);
+ if (words++ == 1) {
+ msg = language_find_message(lang, "MSG_AND");
+ pos += sprintf(output + pos, " %s ", msg);
+ }
+ if (count == 1)
+ msg = language_find_message(lang, unit[type].msg_single);
else
- pos += sprintf(output + pos, "%d %s", count, unit[type].name);
- if (count != 1)
- output[pos++] = 's';
- words++;
+ msg = language_find_message(lang, unit[type].msg_plural);
+ pos += sprintf(output + pos, "%d %s", count, msg);
}
output[pos] = 0;