Upgrading from twitch-irc

Read this guide carefully.

First steps

  • Remove twitch-irc from node_modules and package.json.
  • Install tmi.js npm install tmi.js --save.
  • Change var irc = require("twitch-irc"); to var irc = require("tmi.js");

Configuration

  • Changed default value for reconnect to false.
  • Changed serverType to random.
  • TwitchClient has been deprecated by Twitch.

Events

  • Chat and Action events are now firing when the client sends a message.
  • User object now includes everything sent by Twitch when you receive a message.

    • Changed emote to emotes.
    • Empty tag values are now returning null instead of true.
    • Changed 1 and 0 values to booleans (true and false).
    • Transformed emotes to an object but the raw data is still available as emotes-raw.
    • No more specials tag, use the new user-type by Twitch.
 1{
 2    color: '#FFFFFF',
 3    'display-name': 'Schmoopiie',
 4    emotes: { '25': [ '0-4' ] },
 5    subscriber: false,
 6    turbo: true,
 7    'user-type': 'mod',
 8    'emotes-raw': '25:0-4',
 9    username: 'schmoopiie'
10}
 1client.on("roomstate", function(channel, state) {
 2    console.log(state);
 3});
 4
 5// Returns:
 6{
 7    'broadcaster-lang': null,
 8    r9k: false,
 9    slow: false,
10    'subs-only': false,
11    channel: '#schmoopiie'
12}
  • WHISPER has been added as an event and command. You have to be connected on the group server to send and receive whispers. Twitch is planning to move it to a new system, so it might break in the next weeks / months.
  • HOSTING is now returning the channel name in lowercase and with a hashtag (#channel).

Functions

  • Use client.getUsername() to get the current username.
  • Use client.getOptions() to get the current options.

Utils

  • Removed utils.capitalize, use the display-name value from the user object.
  • Use utils.cronjobs only in Node.js and io.js, it cannot be used in the browser.

Database

  • Changed client.db. to client.nosql.. Change the path of the database using client.nosql.path("./db");.
 1client.nosql.path("./db");
 2
 3client.nosql.insert("monsters", [
 4    {name: "sphinx", mythology: "greek", eyes: 2, sex: "f", hobbies: ["riddles","sitting","being a wonder"]},
 5    {name: "hydra", mythology: "greek", eyes: 18, sex: "m", hobbies: ["coiling","terrorizing","growing"]},
 6    {name: "huldra", mythology: "norse", eyes: 2, sex: "f", hobbies: ["luring","terrorizing"]},
 7    {name: "cyclops", mythology: "greek", eyes: 1, sex: "m", hobbies: ["staring","terrorizing"]},
 8    {name: "fenrir", mythology: "norse", eyes: 2, sex: "m", hobbies: ["growing","god-killing"]},
 9    {name: "medusa",  mythology: "greek", eyes: 2, sex: "f", hobbies: ["coiling","staring"]}
10]).then(function() {
11    console.log("Inserted data, now getting cid 3..");
12
13    client.nosql.get("monsters", 3).then(function(data) {
14        console.log(data);
15    });
16});

Logger

Now compatible for the browser. There is no logging-to-file capabilities and we are not planning to re-add this feature.

Commands

  • Use client.whisper(username, message); to send a whisper. You have to be connected on the group server to send and receive whispers. Twitch is planning to move it to a new system, so it might break in the next weeks / months.

Twitch API / OAuth 2.0

Not yet implemented, use the request module if you need to query the API. This is not a priority for us.