2
0
Fork 0
forked from zynk/zynk

Add !yt YouTube title lookup command via oEmbed API. (0.41.0)

Added new !yt command (cmd_yt.h) that fetches the title and channel name
of a YouTube video using the YouTube oEmbed API. The video URL is
percent-encoded via a new yt_url_encode() helper before being passed as a
query parameter. The JSON response is parsed for 'title' and 'author_name'
fields using the existing json_find() helper, and the result is formatted
as 'Title - Channel'.

- New file: cmd_yt.h with yt_url_encode() and cmd_yt() command handler
- CMakeLists.txt: added WITH_YT feature toggle (ON by default)
- zynk.c: added conditional #include for cmd_yt.h
- irc.h: added cmd_yt() dispatch in handle_privmsg()
- cmd_help.h: added !yt <url> to the help listing
- zynk.c: added doc comments to json_find() function
- cmd_yt.h: added doc comments to yt_url_encode() and cmd_yt()
- CHANGELOG.md: added 0.41.0 entry documenting all changes
- README.md: updated feature summary, features list, feature toggles
  table, minimal build command, and IRC commands utilities table
This commit is contained in:
Johannes Findeisen 2026-07-25 02:17:59 +02:00
commit d59d4dc46c
7 changed files with 186 additions and 27 deletions

View file

@ -1,6 +1,6 @@
# zynk - An IRC bot
An IRC bot in C. Features a key-value store backed by SQLite3, weather lookups via wttr.in, stock quotes, calculator, time, user tracking, and AI-powered replies.
An IRC bot in C. Features a key-value store backed by SQLite3, weather lookups via wttr.in, stock quotes, calculator, time, user tracking, YouTube title lookups, and AI-powered replies.
## This is a fork!
@ -19,6 +19,7 @@ I want to thank Armin for his work and for sharing his code with me. Take a look
- **Offline Messages**: Leave messages for offline users with `!tell`
- **AI Queries**: Ask questions via `!ai` or by addressing the bot; powered by `opencode`
- **Code Changes**: AI-powered code editing with auto-recompile and hot reload
- **YouTube Titles**: Look up video titles with `!yt <url>` (via YouTube oEmbed API)
- **Chat Greetings**: Responds to `hi`, `hello`, `hey`, `bye`, and more
- **Hot Reload**: Reload or restart without leaving channels, losing your nick, or dropping voice mode
- **TLS**: Secure connections via OpenSSL
@ -66,29 +67,30 @@ cmake --build build
Available options (the `!command` shown in parentheses):
| Option | Command | Description | Default |
|-------------------------|------------------|----------------------------------|--------------------------|
| `WITH_ZYNK` | `!zynk` | Key-value store | ON |
| `WITH_PING` | `!ping` | Ping/pong | ON |
| `WITH_VERSION` | `!version` | Version info | ON |
| `WITH_HELP` | `!help` | Help listing | ON |
| `WITH_QUIT` | `!quit` / `!die` | Shut down the bot | ON |
| `WITH_WEATHER` | `!weather` | Weather lookup (requires curl) | ON |
| `WITH_FORECAST` | `!forecast` | 3-day forecast (requires curl) | ON |
| `WITH_STOCK` | `!stock` | Stock quotes (requires curl) | ON |
| `WITH_CALC` | `!calc` | Calculator (requires bc) | ON |
| `WITH_TIME` | `!time` | Time/timezone lookup | ON |
| `WITH_SEEN` | `!seen` | User tracking | ON |
| `WITH_TELL` | `!tell` | Offline messages | ON |
| `WITH_GITLOG` | `!gitlog` | Recent git commits | ON |
| `WITH_CHANGELOG` | `!changelog` | Changelog entries | ON |
| `WITH_AI` | `!ai` | AI questions (requires opencode) | ON (can not be disabled) |
| `WITH_CODE` | `!code` | AI code changes (ops only) | OFF |
| `WITH_REBUILD` | `!rebuild` | Rebuild & restart (ops only) | OFF |
| `WITH_UPTIME` | `!uptime` | Uptime display | ON |
| `WITH_RELOAD` | `!reload` | Hot reload (ops only) | ON |
| `WITH_RESTART` | `!restart` | Restart (ops only) | ON |
| `WITH_GREETING_OR_CHAT` | `<nick>: <text>` | Greeting/chat with AI fallback | ON (can not be disabled) |
| Option | Command | Description | Default |
|-------------------------|------------------|--------------------------------------|--------------------------|
| `WITH_ZYNK` | `!zynk` | Key-value store | ON |
| `WITH_PING` | `!ping` | Ping/pong | ON |
| `WITH_VERSION` | `!version` | Version info | ON |
| `WITH_HELP` | `!help` | Help listing | ON |
| `WITH_QUIT` | `!quit` / `!die` | Shut down the bot | ON |
| `WITH_WEATHER` | `!weather` | Weather lookup (requires curl) | ON |
| `WITH_FORECAST` | `!forecast` | 3-day forecast (requires curl) | ON |
| `WITH_STOCK` | `!stock` | Stock quotes (requires curl) | ON |
| `WITH_CALC` | `!calc` | Calculator (requires bc) | ON |
| `WITH_TIME` | `!time` | Time/timezone lookup | ON |
| `WITH_SEEN` | `!seen` | User tracking | ON |
| `WITH_TELL` | `!tell` | Offline messages | ON |
| `WITH_GITLOG` | `!gitlog` | Recent git commits | ON |
| `WITH_CHANGELOG` | `!changelog` | Changelog entries | ON |
| `WITH_AI` | `!ai` | AI questions (requires opencode) | ON (can not be disabled) |
| `WITH_CODE` | `!code` | AI code changes (ops only) | OFF |
| `WITH_REBUILD` | `!rebuild` | Rebuild & restart (ops only) | OFF |
| `WITH_UPTIME` | `!uptime` | Uptime display | ON |
| `WITH_RELOAD` | `!reload` | Hot reload (ops only) | ON |
| `WITH_RESTART` | `!restart` | Restart (ops only) | ON |
| `WITH_YT` | `!yt` | YouTube title lookup (requires curl) | ON |
| `WITH_GREETING_OR_CHAT` | `<nick>: <text>` | Greeting/chat with AI fallback | ON (can not be disabled) |
### Minimal build
@ -100,7 +102,7 @@ cmake -B build \
-DWITH_STOCK=OFF -DWITH_CALC=OFF -DWITH_TIME=OFF -DWITH_SEEN=OFF \
-DWITH_TELL=OFF -DWITH_GITLOG=OFF -DWITH_CHANGELOG=OFF -DWITH_AI=OFF \
-DWITH_CODE=OFF -DWITH_REBUILD=OFF -DWITH_UPTIME=OFF -DWITH_RELOAD=OFF \
-DWITH_RESTART=OFF -DWITH_GREETING_OR_CHAT=OFF
-DWITH_RESTART=OFF -DWITH_YT=OFF -DWITH_GREETING_OR_CHAT=OFF
cmake --build build
```
@ -173,6 +175,7 @@ rm -rf build
| `!time [timezone]` | Show current time (see below) |
| `!seen <nick>` | Check when a user was last seen |
| `!tell <nick> <message>` | Leave a message for an offline user |
| `!yt <url>` | Show YouTube video title and channel name |
| `!gitlog [count]` | Show recent git commits with links (default: 1, max: 10) |
| `!changelog [count]` | Show changelog entries (default: 1, max: 10) |