# - create an .env file which exports IRC_OAUTH, IRC_CLIENTID, IRC_NICKNAME,
# IRC_CHANNEL and optionally API_CONFIG_FILE
# - create a config/api.json (API_CONFIG_FILE) file which defines api endpoints
# - create src/message_handlers.zig to process recevied messages
source .env
zig build run
zig build test
{
"get_users": {
"type": "Get",
"url": "https://api.twitch.tv/kraken/users?login=${channel}",
"headers": [
"Accept: application/vnd.twitchtv.v5+json",
"Client-ID: ${clientid}"
],
"cached": {
"userid": "users[0]._id",
"name": "users[0].name"
}
}
}
const client = try initClient();
try client.identify();
try client.handle();
Functions which match this signature will be called for PRIVMSGs which begin with '!'. For example, '!name' would call the following handler.
pub fn name(ctx: Context, sender: ?[]const u8, text: ?[]const u8, buf: ?[]u8) anyerror!?[]const u8 {
if (try get_cached("get_users", "name", ctx, sender, text)) |_name| {
return try std.fmt.bufPrint(buf.?, "{}", .{_name});
}
return null;
}
C
Rust