Code Monkey home page Code Monkey logo

tmi-rs's Introduction

tmi-rs โ€ƒ Documentation Latest Version

Blazingly fast ๐Ÿš€ Rust ๐Ÿฆ€ library for interacting with twitch.tv's chat interface.

Quick Start

$ cargo add tmi anyhow tokio -F tokio/full
const CHANNELS: &[&str] = &["#forsen"];

#[tokio::main]
async fn main() -> anyhow::Result<()> {
  let mut client = tmi::Client::anonymous().await?;
  client.join_all(CHANNELS).await?;

  loop {
    let msg = client.recv().await?;
    match msg.as_typed()? {
      tmi::Message::Privmsg(msg) => {
        println!("{}: {}", msg.sender().name(), msg.text());
      }
      tmi::Message::Reconnect => {
        client.reconnect().await?;
        client.join_all(CHANNELS).await?;
      }
      tmi::Message::Ping(ping) => {
        client.pong(&ping).await?;
      }
      _ => {}
    }
  }
}

Performance

Calling the library blazingly fast is done in jest, but it is true that tmi-rs is very fast. tmi-rs is part of the twitch-irc-benchmarks, where it is currently the fastest implementation by a significant margin (nearly 6x faster than the second best Rust implementation). This is because underlying IRC message parser is handwritten and accelerated using SIMD on x86 and ARM. For every other architecture, there is a scalar fallback.

Acknowledgements

Initially based on dank-twitch-irc, and twitch-irc-rs. Lots of test messages were taken directly from twitch-irc-rs.

tmi-rs's People

Contributors

jprochazk avatar optimalstrategy avatar vesdev 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.