Giter Site home page Giter Site logo

zig-ircbot's Introduction

Quick Start

# - 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

Testing

zig build test

config/api.json

{
    "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"
            }
    }
}

src/main.zig

     const client = try initClient();
    try client.identify();
    try client.handle();

src/message_handlers.zig

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;
}

Reference Projects

C

https://github.com/andrew-stclair/simple-irc-bot/

Rust

https://github.com/aatxe/irc

References

zig-ircbot's People

Contributors

travisstaloch avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.