diff options
-rw-r--r-- | pttbbs/mbbsd/ccw.c | 24 | ||||
-rw-r--r-- | pttbbs/util/xchatd.c | 37 |
2 files changed, 31 insertions, 30 deletions
diff --git a/pttbbs/mbbsd/ccw.c b/pttbbs/mbbsd/ccw.c index 3b142400..d31110d6 100644 --- a/pttbbs/mbbsd/ccw.c +++ b/pttbbs/mbbsd/ccw.c @@ -806,6 +806,7 @@ ccw_chat_prompt(CCW_CTX *ctx) prints("%-*s》", CHAT_ID_LEN, ctx->local_id); } +#ifdef EXP_CHAT_HIGHLIGHTS static int word_match_index(const char *buf, const char *pattern, size_t szpat) { @@ -857,12 +858,14 @@ ccw_chat_print_highlights(CCW_CTX *ctx, const char *s) outs(s); } } +#endif // EXP_CHAT_HIGHLIGHTS static void ccw_chat_print_line(CCW_CTX *ctx, const char *buf, int local) { - assert(local != CCW_LOCAL); +#ifdef EXP_CHAT_HIGHLIGHTS size_t szid; + // let's try harder to recognize the content if (local != CCW_REMOTE || buf[0] == ' '|| strchr(buf, ESC_CHR) || !strchr(buf, ':') ) @@ -883,6 +886,10 @@ ccw_chat_print_line(CCW_CTX *ctx, const char *buf, int local) // message from others ccw_chat_print_highlights(ctx, buf); } +#else // !EXP_CHAT_HIGHLIGHTS + outs(buf); +#endif // !EXP_CHAT_HIGHLIGHTS + assert(local != CCW_LOCAL); outs(ANSI_RESET "\n→"); } @@ -965,6 +972,8 @@ ccw_chat_recv(CCW_CTX *ctx) return 0; } +#ifdef EXP_ANTIFLOOD + // prevent flooding */ static void ccw_chat_anti_flood(CCW_CTX *ctx) @@ -998,6 +1007,7 @@ ccw_chat_anti_flood(CCW_CTX *ctx) ext->flood = 0; } } +#endif // EXP_ANTIFLOOD static int ccw_chat_peek_cmd(CCW_CTX *ctx, const char *buf, int local) @@ -1113,18 +1123,6 @@ ccw_chat_peek_key(CCW_CTX *ctx, int key) ccw_chat_check_newmail(ctx); return 1; - case Ctrl('I'): - { - VREFSCR scr = vscr_save(); - add_io(0, 0); - - t_idle(); - - add_io(ctx->fd, 0); - vscr_restore(scr); - } - return 1; - // Support ZA because chat is mostly independent and secure. case Ctrl('Z'): { diff --git a/pttbbs/util/xchatd.c b/pttbbs/util/xchatd.c index 75c49e59..1436fd14 100644 --- a/pttbbs/util/xchatd.c +++ b/pttbbs/util/xchatd.c @@ -796,7 +796,7 @@ chat_topic(ChatUser *cu, char *msg) room_changed(room); - sprintf(chatbuf, "◆ %s 將話題改為 [1;32m%s[m", cu->chatid, topic); + sprintf(chatbuf, "◆ %s 將話題改為 " ANSI_COLOR(1;32) "%s" ANSI_RESET, cu->chatid, topic); if (!CLOAK(cu)) /* Thor: 聊天室隱身術 */ send_to_room(room, chatbuf, 0, MSG_MESSAGE); } @@ -831,7 +831,7 @@ chat_nick(ChatUser *cu, char *msg) return; } - snprintf(chatbuf, sizeof(chatbuf), "※ %s 將聊天代號改為 [1;33m%s[m", cu->chatid, chatid); + snprintf(chatbuf, sizeof(chatbuf), "※ %s 將聊天代號改為 " ANSI_COLOR(1;33) "%s" ANSI_RESET, cu->chatid, chatid); if (!CLOAK(cu)) /* Thor: 聊天室隱身術 */ send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE); @@ -861,7 +861,9 @@ chat_list_rooms(ChatUser *cuser, char *msg) if (common_client_command) send_to_user(cuser, "", 0, MSG_ROOMLISTSTART); else - send_to_user(cuser, "[7m 聊天室名稱 │人數│話題 [m", 0, MSG_MESSAGE); + send_to_user(cuser, ANSI_COLOR(7) " 聊天室名稱 │人數│話題" + " " // 48-4 spaces for max topic length + ANSI_RESET, 0, MSG_MESSAGE); for(cr = &mainroom; cr; cr = cr->next) { if (!SECRET(cr) || CHATSYSOP(cuser) || (cr == cuser->room && ROOMOP(cuser))) @@ -910,7 +912,7 @@ chat_do_user_list(ChatUser *cu, char *msg, ChatRoom *theroom) if (common_client_command) send_to_user(cu, "", 0, MSG_USERLISTSTART); else - send_to_user(cu, "[7m 聊天代號│使用者代號 │聊天室 [m", 0, MSG_MESSAGE); + send_to_user(cu, ANSI_COLOR(7) " 聊天代號│使用者代號 │聊天室 " ANSI_RESET, 0, MSG_MESSAGE); for (user = mainuser; user; user = user->unext) { @@ -1013,7 +1015,7 @@ chat_map_chatids(ChatUser *cu, ChatRoom *whichroom) /* Thor: 還沒有作不同間的 */ myroom = whichroom; send_to_user(cu, - "[7m 聊天代號 使用者代號 │ 聊天代號 使用者代號 │ 聊天代號 使用者代號 [m", 0, MSG_MESSAGE); + ANSI_COLOR(7) " 聊天代號 使用者代號 │ 聊天代號 使用者代號 │ 聊天代號 使用者代號 " ANSI_RESET, 0, MSG_MESSAGE); c = 0; @@ -1159,7 +1161,7 @@ chat_private(ChatUser *cu, char *msg) else if (*msg) { userno = cu->userno; - sprintf(chatbuf, "[1m*%s (%s)*[m ", cu->chatid, cu->userid); + sprintf(chatbuf, ANSI_COLOR(1) "*%s (%s)*" ANSI_RESET " ", cu->chatid, cu->userid); strncat(chatbuf, msg, 80); send_to_user(xuser, chatbuf, userno, MSG_MESSAGE); @@ -1234,7 +1236,8 @@ arrive_room(ChatUser *cuser, ChatRoom *room) send_to_user(cuser, chatbuf, 0, 0); } - sprintf(chatbuf, "※ [32;1m%s (%s)[m 進入 [33;1m[%s][m 包廂", + sprintf(chatbuf, "※ " ANSI_COLOR(1;32) "%s (%s)" ANSI_RESET " 進入 " + ANSI_COLOR(1;33) "[%s]" ANSI_RESET " 包廂", cuser->chatid, cuser->userid, rname); if (!CLOAK(cuser)) /* Thor: 聊天室隱身術 */ send_to_room(room, chatbuf, cuser->userno, MSG_MESSAGE); @@ -1386,10 +1389,10 @@ print_user_counts(ChatUser *cuser) number = (cuser->clitype) ? MSG_MOTD : MSG_MESSAGE; sprintf(chatbuf, - "☉ 歡迎光臨【批踢踢茶藝館】,目前開了 [1;31m%d[m 間包廂", roomc); + "☉ 歡迎光臨【批踢踢茶藝館】,目前開了 " ANSI_COLOR(1;31) "%d" ANSI_RESET " 間包廂", roomc); send_to_user(cuser, chatbuf, 0, number); - sprintf(chatbuf, "☉ 共有 [1;36m%d[m 人來擺\龍門陣", 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); @@ -1566,7 +1569,7 @@ chat_act(ChatUser *cu, char *msg) { if (*msg && (!RHANDUP(cu->room) || SAY(cu) || ROOMOP(cu))) { - sprintf(chatbuf, "%s [36m%s[m", cu->chatid, msg); + sprintf(chatbuf, "%s " ANSI_COLOR(36) "%s" ANSI_RESET, cu->chatid, msg); send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE); } } @@ -1984,7 +1987,7 @@ chat_broadcast(ChatUser *cu, char *msg) send_to_user(cu, "※ 請指定廣播內容", 0, MSG_MESSAGE); return; } - sprintf(chatbuf, "[1m※ " BBSNAME "聊天室廣播中 [%s].....[m", + sprintf(chatbuf, ANSI_COLOR(1) "※ " BBSNAME "聊天室廣播中 [%s]....." ANSI_RESET, cu->chatid); send_to_room(ROOM_ALL, chatbuf, 0, MSG_MESSAGE); sprintf(chatbuf, "◆ %s", msg); @@ -2145,7 +2148,7 @@ party_action(ChatUser *cu, char *cmd, char *party) party = xuser->chatid; } } - sprintf(chatbuf, "[1;32m%s [31m%s[33m %s [31m%s[m", + sprintf(chatbuf, ANSI_COLOR(1;32) "%s " ANSI_COLOR(31) "%s" ANSI_COLOR(33) " %s " ANSI_COLOR(31) "%s" ANSI_RESET, cu->chatid, cap->part1_msg, party, cap->part2_msg); send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE); return 0; @@ -2202,7 +2205,7 @@ speak_action(ChatUser *cu, char *cmd, char *msg) { if (!str_equal(cmd, verb)) continue; - sprintf(chatbuf, "[1;32m%s [31m%s:[33m %s[m", + sprintf(chatbuf, ANSI_COLOR(1;32) "%s " ANSI_COLOR(31) "%s:" ANSI_COLOR(33) " %s" ANSI_RESET, cu->chatid, cap->part1_msg, msg); send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE); return 0; @@ -2279,7 +2282,7 @@ condition_action(ChatUser *cu, char *cmd) { if (str_equal(cmd, verb)) { - sprintf(chatbuf, "[1;32m%s [31m%s[m", + sprintf(chatbuf, ANSI_COLOR(1;32) "%s " ANSI_COLOR(31) "%s" ANSI_RESET, cu->chatid, cap->part1_msg); send_to_room(cu->room, chatbuf, cu->userno, MSG_MESSAGE); return 1; @@ -2296,9 +2299,9 @@ condition_action(ChatUser *cu, char *cmd) static char *dscrb[] = { - "[1;37m【 Verb + Nick: 動詞 + 對方名字 】[36m 例://kick piggy[m", - "[1;37m【 Verb + Message:動詞 + 要說的話 】[36m 例://sing 天天天藍[m", - "[1;37m【 Verb:動詞 】 ↑↓:舊話重提[m", NULL + ANSI_COLOR(1;37) "【 Verb + Nick: 動詞 + 對方名字 】" ANSI_COLOR(36) " 例://kick piggy" ANSI_RESET, + ANSI_COLOR(1;37) "【 Verb + Message:動詞 + 要說的話 】" ANSI_COLOR(36) " 例://sing 天天天藍" ANSI_RESET, + ANSI_COLOR(1;37) "【 Verb:動詞 】 ↑↓:舊話重提" ANSI_RESET, NULL }; ChatAction *catbl[] = { |