diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-24 12:19:40 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-10-24 12:19:40 +0800 |
commit | 3f50fed1ff50307ba55dc07f8826a019f41d0f68 (patch) | |
tree | 3c32c0592073e35a9c1a96eacf38a5b7eafd2e0c | |
parent | 461657c3d8be7a8d590d5b657e384eaafdb9e882 (diff) | |
download | pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar.gz pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar.bz2 pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar.lz pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar.xz pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.tar.zst pttbbs-3f50fed1ff50307ba55dc07f8826a019f41d0f68.zip |
* xchatd: add xinfo command to report server status
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@4974 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/util/xchatd.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/pttbbs/util/xchatd.c b/pttbbs/util/xchatd.c index 3cdfb814..b343828e 100644 --- a/pttbbs/util/xchatd.c +++ b/pttbbs/util/xchatd.c @@ -150,6 +150,7 @@ static char msg_no_such_id[] = "◆ 目前沒有人使用 [%s] 這個聊天代號"; static char msg_no_such_uid[] = "◆ 目前沒有 [%s] 這個使用者 ID"; static char msg_not_here[] = "◆ [%s] 不在這間聊天室"; +time4_t boot_time; #define FUZZY_USER ((ChatUser *) -1) @@ -605,6 +606,7 @@ send_to_room(ChatRoom *room, char *msg, int userno, int number) static void send_to_user(ChatUser *user, char *msg, int userno, int number) { + // BBS clients does not take non MSG_MESSAGE if (number && number != MSG_MESSAGE) return; @@ -769,6 +771,20 @@ chat_version(ChatUser *cu, char *msg) } static void +chat_xinfo(ChatUser *cu, char *msg) +{ + // report system information + time4_t uptime = time(0) - boot_time; + int dd = uptime / DAY_SECONDS, + hh = (uptime % DAY_SECONDS) / 3600, + mm = (uptime % 3600) / 60; + sprintf(chatbuf, "☉ 系統資訊: XCHAT 版本 %d.%02d - " __DATE__ + ",已執行 %d 天 %d 小時 %d 分", + XCHAT_VERSION_MAJOR, XCHAT_VERSION_MINOR, dd, hh, mm); + send_to_user(cu, chatbuf, 0, MSG_MESSAGE); +} + +static void chat_nick(ChatUser *cu, char *msg) { char *chatid; @@ -1327,11 +1343,12 @@ print_user_counts(ChatUser *cuser) number = MSG_MESSAGE; - sprintf(chatbuf, - "☉ 歡迎光臨【批踢踢茶藝館】,目前開了 " ANSI_COLOR(1;31) "%d" ANSI_RESET " 間包廂", roomc); + // welcome message here. + sprintf(chatbuf, "☉ 歡迎光臨【批踢踢聊天室】,目前開了 " + ANSI_COLOR(1;31) "%d" ANSI_RESET " 間包廂。", roomc); send_to_user(cuser, chatbuf, 0, number); - sprintf(chatbuf, "☉ 共有 " ANSI_COLOR(1;36) "%d" ANSI_RESET " 人來擺\龍門陣", userc); + sprintf(chatbuf, "☉ 線上有 " ANSI_COLOR(1;36) "%d" ANSI_RESET " 人", userc); if (suserc) sprintf(chatbuf + strlen(chatbuf), " [%d 人在秘密聊天室]", suserc); send_to_user(cuser, chatbuf, 0, number); @@ -2364,6 +2381,7 @@ static ChatCmd chatcmdlist[] = {"list", chat_list_users, 0}, {"topic", chat_topic, 1}, {"version", chat_version, 1}, + {"xinfo", chat_xinfo, 1}, {NULL, NULL, 0} }; @@ -2882,6 +2900,7 @@ main(int argc, char *argv[]) setgid(BBSGID); setuid(BBSUID); + boot_time = time(0); log_init(); // Signal(SIGBUS, SIG_IGN); |