getting_started - YoYoGames/GMEXT-Twitch GitHub Wiki

Getting Started

This page provides basic information on how to get started with the Twitch extension in your GameMaker project.

Authentication

Twitch Reference: Authentication

To authenticate with Twitch, use twitch_auth or twitch_auth_from_cache:

twitch_auth([TWITCH_SCOPE_USER_EDIT],,,
    function(_data)
    {
        show_debug_message("Authentication Successful!");
    },
    function(_data)
    {
        show_debug_message("Authentication Failed.");
    }
);

Pass the Scopes to twitch_auth as well as a success callback and failure callback function.

[!NOTE]

The Twitch extension automatically refreshes the token periodically, so in general you shouldn't need to call twitch_auth_refresh_token manually.

[!NOTE]

twitch_auth_from_cache can only be used if cached credentials exist, i.e. if the user was authenticated before using twitch_auth.

Callback Functions

The Twitch extension uses callback functions that you pass to the functions (rather than async events). Functions take a success callback and a failure callback. The success callback is called if the function succeeds, the failure callback is called if it fails. These functions take a single parameter that holds the data returned by Twitch. In the extension you access this as a Struct. See the success callback of a function for detailed information on the data it returns.

Parsing Chat Messages

The Twitch extension comes with example code in twitch_parse_message(), which performs basic chat message parsing. The code is based on example code which was previously available in the Twitch documentation. It can be used as a starting point for your own message parsing code, though will be removed when it is out-of-date with Twitch's IRC interface.

See the Twitch documentation on IRC Concepts for the latest up-to-date information on how to parse IRC messages.