Welcome message for new users, channel tracking docs. (0.41.2)
- Added welcome message when users join a channel: handle_join() now sends "Welcome, <nick>!" to the channel for non-bot users. The bot's own joins are silently ignored to avoid echo loops. - Added src_nick parameter to handle_join() to identify the joining user; the call site in irc_handle() was updated to pass src_nick. - Added doc comments to chans[] (global channel tracking array) and nchans (count of tracked channels) in irc.h. - Bumped version to 0.41.2 in CMakeLists.txt.
This commit is contained in:
parent
0f0e6a5b1b
commit
84fd78f0a0
3 changed files with 35 additions and 10 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
2026.07.25 - Welcome message for new users, channel tracking docs. (0.41.2)
|
||||||
|
|
||||||
|
- Added a welcome message when users join a channel: `handle_join()` now sends `"Welcome, <nick>!"` to the channel for non-bot users. The bot's own joins are silently ignored to avoid echo loops.
|
||||||
|
- Added `src_nick` parameter to `handle_join()` to identify the joining user; the call site in `irc_handle()` was updated to pass `src_nick`.
|
||||||
|
- Added doc comments to `chans[]` (global channel tracking array) and `nchans` (count of tracked channels) in `irc.h`.
|
||||||
|
|
||||||
2026.07.25 - Decode Unicode escapes in !yt responses. (0.41.1)
|
2026.07.25 - Decode Unicode escapes in !yt responses. (0.41.1)
|
||||||
|
|
||||||
- Fixed `!yt` displaying raw JSON Unicode escape sequences (e.g. `\u0027` instead of `'`) in video titles and channel names. YouTube's oEmbed API returns non-ASCII characters as `\uXXXX` escapes, which were previously passed through as-is.
|
- Fixed `!yt` displaying raw JSON Unicode escape sequences (e.g. `\u0027` instead of `'`) in video titles and channel names. YouTube's oEmbed API returns non-ASCII characters as `\uXXXX` escapes, which were previously passed through as-is.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
project(zynk VERSION 0.41.1 LANGUAGES C)
|
project(zynk VERSION 0.41.2 LANGUAGES C)
|
||||||
|
|
||||||
# Prefer C99; the code is compatible with C99/C11
|
# Prefer C99; the code is compatible with C99/C11
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
|
||||||
33
irc.h
33
irc.h
|
|
@ -25,7 +25,21 @@ int valid_irc_word(const char *s) {
|
||||||
|
|
||||||
/* ---- channel op tracking ---- */
|
/* ---- channel op tracking ---- */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* chans - Array of tracked channel entries.
|
||||||
|
*
|
||||||
|
* Holds up to MAX_CHANS channel records, each containing the channel name
|
||||||
|
* and its list of operator nicks. Populated via chan_get_or_add() when JOIN
|
||||||
|
* messages or NAMREPLY (353) responses are received.
|
||||||
|
*/
|
||||||
ChanEntry chans[MAX_CHANS];
|
ChanEntry chans[MAX_CHANS];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nchans - Number of currently tracked channels.
|
||||||
|
*
|
||||||
|
* Tracks how many entries in the chans[] array are in use. Incremented by
|
||||||
|
* chan_get_or_add() when a new channel is registered.
|
||||||
|
*/
|
||||||
int nchans;
|
int nchans;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -493,25 +507,30 @@ static void handle_mode(Session *s, const char *params) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* handle_join - Process JOIN messages to register new channels.
|
* handle_join - Process JOIN messages to register channels and welcome users.
|
||||||
*
|
*
|
||||||
* When any user (including the bot) joins a channel, registers the channel
|
* When any user joins a channel, registers the channel in the tracking array
|
||||||
* in the tracking array via chan_get_or_add(). This ensures the channel
|
* via chan_get_or_add(). If the joining user is not the bot itself, sends a
|
||||||
* exists in the ops tracking structure even before NAMREPLY arrives.
|
* simple welcome message to the channel.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* s - The IRC session.
|
* s - The IRC session.
|
||||||
* params - The raw IRC params (:#channel).
|
* params - The raw IRC params (:#channel).
|
||||||
|
* src_nick - The nick of the user who joined.
|
||||||
*
|
*
|
||||||
* Returns: void.
|
* Returns: void.
|
||||||
*/
|
*/
|
||||||
static void handle_join(Session *s, const char *params) {
|
static void handle_join(Session *s, const char *params, const char *src_nick) {
|
||||||
(void)s;
|
|
||||||
const char *p = params;
|
const char *p = params;
|
||||||
if (*p == ':') p++;
|
if (*p == ':') p++;
|
||||||
char _chan[64];
|
char _chan[64];
|
||||||
if (sscanf(p, "%63s", _chan) == 1)
|
if (sscanf(p, "%63s", _chan) == 1)
|
||||||
chan_get_or_add(_chan);
|
chan_get_or_add(_chan);
|
||||||
|
if (src_nick && strcasecmp(src_nick, s->nick) != 0) {
|
||||||
|
char welcome[256];
|
||||||
|
snprintf(welcome, sizeof welcome, "Welcome, %s! User zynk is an AI driven bot using OpenCode. You can ask the bot whatever you want... have fun! ;)", src_nick);
|
||||||
|
irc_msg(s, _chan, welcome);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -730,7 +749,7 @@ static void irc_handle(Session *s, const char *raw) {
|
||||||
if (strcmp(cmd_buf, "PRIVMSG") == 0) { handle_privmsg(s, params, src_nick); return; }
|
if (strcmp(cmd_buf, "PRIVMSG") == 0) { handle_privmsg(s, params, src_nick); return; }
|
||||||
if (strcmp(cmd_buf, "353") == 0) { handle_namreply(s, params); return; }
|
if (strcmp(cmd_buf, "353") == 0) { handle_namreply(s, params); return; }
|
||||||
if (strcmp(cmd_buf, "MODE") == 0) { handle_mode(s, params); return; }
|
if (strcmp(cmd_buf, "MODE") == 0) { handle_mode(s, params); return; }
|
||||||
if (strcmp(cmd_buf, "JOIN") == 0 && prefix) { handle_join(s, params); return; }
|
if (strcmp(cmd_buf, "JOIN") == 0 && prefix) { handle_join(s, params, src_nick); return; }
|
||||||
if (strcmp(cmd_buf, "PART") == 0 && prefix) { handle_part(params, src_nick); return; }
|
if (strcmp(cmd_buf, "PART") == 0 && prefix) { handle_part(params, src_nick); return; }
|
||||||
if (strcmp(cmd_buf, "KICK") == 0 && prefix) { handle_kick(params); return; }
|
if (strcmp(cmd_buf, "KICK") == 0 && prefix) { handle_kick(params); return; }
|
||||||
if (strcmp(cmd_buf, "QUIT") == 0 && prefix) { handle_quit_net(src_nick); return; }
|
if (strcmp(cmd_buf, "QUIT") == 0 && prefix) { handle_quit_net(src_nick); return; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue