Giter VIP home page Giter VIP logo

twitch4j's Introduction

Java API for Twitch

Support:

Discord Server Twitch API Server

Badges:

Latest Docs Javadoc


A quick note:

This project implements client modules to interact with all of Twitch's APIs.

Quick Start

Check out the Documentation!


Modules

Project

Module Description
chat Chat (IRC)
eventsub-common EventSub (can be used for Webhook-Transport)
eventsub-websocket EventSub (WebSocket & Conduits)
helix REST-API
pubsub PubSub
graphql GraphQL (unofficial)
kotlin Kotlin Extensions

Shared

Module Description
cache-api In-Memory Cache API
event4j Event Publication and Subscription

The shared libraries offer standardized functionality in an abstracted manner, allowing you to select from a variety of implementations (or bring your own).

Problems

If you have problems using the Twitch Java API, then you are welcome to join the discord server to talk about it.

If you discover any issues/have feature requests, then please open an issue here.

Contributing

We welcome contributions to the library, be it new features, bug fixes, or even small enhancements. Please do read the contributing guide on the documentation site as it provides code guidelines and helpful tips for getting started. By contributing, you are expected to abide by our code of conduct and agree to the license below. Thank you again for your interest in improving Twitch4J!

License

Released under the MIT license.

twitch4j's People

Contributors

belchingjalapeno avatar boostchicken avatar dependabot-preview[bot] avatar dependabot[bot] avatar dersimeon avatar github-actions[bot] avatar iprodigy avatar jaronsummers avatar jonteohr avatar kaufisch avatar lunarwatcher avatar maciejgorczyca avatar maximkulikov avatar mohamed-tayeh avatar p4czyk avatar philippheuer avatar potb avatar renovate[bot] avatar samfundev avatar sethfalco avatar sg4e avatar sgdc3 avatar skillkiller avatar somniumprime avatar stachu540 avatar stepango avatar subside avatar tadite avatar tedyoung avatar waridley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

twitch4j's Issues

Support for moderators actions in Pubsub

Description

As discussed on Discord, I suggest the implementation of the official-ish mod actions topic.
This topic adds the ability to log any actions made by a moderator (or the broadcaster himself) such as bans, unbans, timeouts and untimeouts (yes, that's a thing).
It gives information about the moderator who made the action (where its irc counterpart only gives info about the user who got banned / timed out).

Documentation

As this topic is created by Twitch but not put in the official documentation, the docs are located in the forums here.

Consider adding an optional authorization parameter to the Helix unauthenticated metods, to alleviate rate limits.

Prerequisites

Description

Accessing the unauthenticated Helix-api methods without a bearer token, significantly reduces the api limits.
Consider adding auth-token as an optional parameter to the unauthenticated methods.

Solutions

Consider adding an optional authorization parameter, to the TwitchHelix.java methods which currently does not require it.

This since adding a valid bearer token (either user access token or application specific app access token) will increase the rate limit from 30 calls per minute to 800 calls per minute (per token). This would make it more efficient to poll for e.g. follower changes. This could also be used to optimize the TwitchClientHelper.

Alternatives

Since the unauthenticated rate limits are globally enforced on a per IP-address level, currently the only workaround is either to use longer polling intervals, or several external IP-adresses. Neither of which will scale very well, especially if polling e.g. followers for multiple channels, since the limits will be enforced across all the channels (instead on a per-user basis).

Additional context

API limits as described here:
https://dev.twitch.tv/docs/api/guide/#rate-limits

Video Uploads

Description

Video uploads is a service using Kraken API to create upload sequence, commence and upload your video with returns video data.

Steps to Reproduce

  1. Create uploads using VideoService#createUpload(<credential/video_file>)
  2. with using method createUpload building some queries for API to initiate uploading, using parameters below
  • Title (Important thing to commence upload)
  • Channel - if is not specify, will start uploading to your own authorized user channel
  • Description
  • Game
  • Language
  • Tags (character restrictions)
  • Viewable Type - specify if you want videos Public or Private (Enums here)
  • Viewable At - When will be Available to Public (if viewable type is Private)
  1. To start upload file we must specify video file or credential with available authorized scope channel_editor. There is some condition must be met:
  • If channel is specified, authorized user must have a Channel Editor plivigers into specific channel.
  • File must be a Video Format
  • If video doesn't match following formats below will convert into FLV or MP4 (discuss required)
    Following formats required by Twitch:
    • MP4, MOV, AVI and FLV file formats
    • AAC audio
    • h264 codec
    • Up to 10Mbps bitrate - important
    • Up to 1080p/60FPS - important
  1. Following Video Upload Guide we reproducing uploading Thread with Cancelable actions (Yes, will be reactive). Video parts must contains a byte[] parts with 5-25MB. All parts cannot be exceed to 10GB (throwing LimitExceededException)
  2. Complete uploads with receive Video data information received from Twitch.

Expected behavior:
Most parts will allows to uploading any videos converting discussed file format.
Actual behavior:
Discussing
Stacktrace (if applicable):

  • ScopeIsMissingException - if authorized user doesn't have channel_editor scope
  • AccessDeniedException - authorized user is not channel editor on specific channel
  • LimitExceededException - if uploaded file is to big (max. 10GB)
  • IllegalFormatException - if file is not video, doesn't met requirements with bitrate or it is higher than 1080p/60FPS
  • IOException - other way will be thrown while initialize uploads creates thread.
    Version affected:
    v1.+ - this is a feature

Additional Information

Because this is a feature, I want to hear you ideas. First one to proceed uploading file will be check if it is a video. Next step is checking metadada using this library is some parts doesn't following formats will be converted to appropriate file format. And final step is start upload with progression.

Access Tokens

Please add a feature to allow getting access tokens from twitch, and the ability for the library to use them in TwitchClientHelper.

I realized there is no way to use a token in the TwitchClientHelper, and when I run my program I get 401 errors from the Twitch API saying the "OAuth token is missing". And looking at the source code, it just uses null as the token.

Thanks

Number of months for resub events is inaccurate

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Looked at the code and the Twitch API docs. msg-param-months is what Twitch4j parses for the SubscriptionEvent's getMonths() method. Here's what the Twitch API docs say about that parameter:

(Sent only on subgift, anonsubgift) The total number of months the user has subscribed. This is the same as msg-param-cumulative-months but sent for different types of user notices.

Here's msg-param-cumulative-months:

(Sent only on sub, resub) The total number of months the user has subscribed. This is the same as msg-param-months but sent for different types of user notices.

...which is bizarre. Twitch felt it was important to use distinct parameters for # of months subscribed dependent on whether the current resub was from a giftsub or regular sub.
Sub streak is a completely separate parameter: msg-param-streak-months.
Looking at the Twitch4j documentation, I can't determine what is specified to be returned from SubscriptionEvent.getMonths(); it's merely specified as months.
In my opinion getMonths() should return cumulative months subscribed and new methods should be introduced to query sub streak (which the subscriber can choose to share or hide).
Currently getMonths() is accurate only if it's a 1st-time sub or a giftsub.

Steps to Reproduce

Listen for subscription events in a channel and compare sub-months to what SubscriptionEvent.getMonths() reports.


Expected behavior:
Should return correct sub-month count.

Actual behavior:
Only accurate for giftsubs.

Stacktrace (if applicable):

Version affected:

Additional Information

Modules Support

Prerequisites

  • If this is a question/suggestion, I have already considered talking about it on Discord
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Twitch4J Modules... sounds good. Will be works like D4J modules. All features will be referenced and refactored into the current codestyle script, includes Lombok stuff.

Steps to Reproduce

Reference reproducing modules from D4J

Expected behavior: Loading class from Jar. Searching for implemented Class or checking MANIFEST.MF attribute Twitch4J-ModuleClass existance.

Actual behavior: Getting modules list.

Stacktrace (if applicable): Stacktrace for ClassNotFound, ClassCast, etc. without adding module.

Version affected: latest

Additional Information

Modules will be helpful for adding stuff on the fly. All current stuff: StreamLabs, Commands, etc. will be separate from core script and adding like new project, extended class implementation or defined attribute from manifest file.

Jcenter JARs all have old me.philippheuer class names

I was trying to use Jcenter to import this library into my project but all of the JAR files there have old me.philippheuer class names

I downloaded a few of them to manually inspect the JAR and ran the following command

jar tvf twitch4j.jar

     0 Wed Sep 19 17:38:42 MDT 2018 META-INF/
    25 Wed Sep 19 17:38:42 MDT 2018 META-INF/MANIFEST.MF
     0 Wed Sep 19 17:38:40 MDT 2018 me/
     0 Wed Sep 19 17:38:40 MDT 2018 me/philippheuer/
     0 Wed Sep 19 17:38:42 MDT 2018 me/philippheuer/twitch4j/
     0 Wed Sep 19 17:38:42 MDT 2018 me/philippheuer/twitch4j/model/
  1852 Wed Sep 19 17:38:42 MDT 2018 me/philippheuer/twitch4j/model/BlockList.class
  2103 Wed Sep 19 17:38:42 MDT 2018 me/philippheuer/twitch4j/model/TopGame.class
   ...

Am I doing something wrong? Is Jcenter not being used anymore?

I checked both of these to make sure I wasn't hitting the wrong one due to capitalization.
https://jcenter.bintray.com/com/github/twitch4j/twitch4j/v0.12.0/:twitch4j-v0.12.0.jar
https://jcenter.bintray.com/com/github/twitch4j/Twitch4J/v0.12.0/:Twitch4J-v0.12.0.jar

ChannelGoLiveEvent doesn't trigger everytime

I don't know exactly why, but ChannelGoLiveEvent doesn't trigger everytime. Sometimes it works 3 days without any problem, and then nothing. However, ChannelGoOfflineEvent works perfectly.
It seems to happen everytime a replay is started on the channel.
Here is the code »
twitchClient.getEventManager().onEvent(ChannelGoOfflineEvent.class).subscribe((channelGoOfflineEvent) -> {/*insert code*/});

Before you ask, no, there isn't any errors, and I already tried to put only a sysout and it does not trigger.

Using 1.0.0-alpha.11 via Maven.

[IRC] Chat Rooms

Description

Chat rooms now is officially documented on Twitch Developer Site

Steps to Reproduce

  1. Getting chat rooms via API
  2. Reproduce chat rooms cache inside IChannel interface and his implementation.
  3. Reproduce exception access into chat rooms.
  4. Dispatch event: ChatRoomMessageEvent will extended OrdinalMessageEvent. MessageEvent will be class for customize own message event.

Build a fat JAR

Hi, I hate Gradle etc.

How can I build as a twitch4j as a fat jar?

Thanks

NullPointerException when registering a ("dynamic") command when auto save configuration is disabled

Prerequisites

  • If this is a question/suggestion, I have already considered talking about it on Discord
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

When creating a TwitchClientBuilder and including .withAutoSaveConfiguration(false), I will get a stack trace when trying to register a command in said TwitchClient's CommandHandler. The stack trace only occurs when trying to register an instance of a Command (i.e. TestCommand()), not when registering the class (TestCommand.class).

Triggers stack trace

TestCommand command = new TestCommand();
twitchClient.getCommandHandler().registerCommand(command);

No stack trace

twitchClient.getCommandHandler().registerCommand(TestCommand.class);

Steps to Reproduce

  1. Create a TwitchClient instance via the TwitchClientBuilder (making sure to use .withAutoSaveConfiguration(false) )
TwitchClient twitchClient = TwitchClientBuilder.init()
	.withClientId("")
	.withClientSecret("")
	.withAutoSaveConfiguration(false)
	.withCredential("") 
	.connect();
  1. Create an instance of a class that extends the Command class
TestCommand command = new TestCommand();
  1. Register the command in the TwitchClient instance's CommandHandler
twitchClient.getCommandHandler().registerCommand(command);

Expected behavior:
The Command should register with not stack trace.

Actual behavior:
The Command is registered to the CommandHandler and I am able to use it in Twitch chat, however I get a stack trace during the registration.

Stacktrace (if applicable):
https://hastebin.com/ehiwuxelar.xml

Version affected:
0.10.1

Additional Information

I believe this is a bug because of the logic of the method where the exception occurs.

public void saveDynamicCommands() {
		try {
			// Get all Dynamic Commands
			List<Command> commandList = getCommandMap().values().stream().filter(e -> e instanceof DynamicCommand).collect(Collectors.toList());

			// Save List to File
			ObjectMapper mapper = new ObjectMapper();
			mapper.writeValue(getCommandSaveFile(), commandList);

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

The exception occurs at the line mapper.writeValue(getCommandSaveFile(), commandList); (line 283). A NullPointerException is thrown because there is no command save file because saving configurations was disabled when creating the TwitchClient instance. If users are given the option to disable saving configurations, then either the exception should be handled quietly or there should be logic to check the user's preferences before attempting to write to the file and printing the error.

I tried to test this theory by enabling saving configurations (.withAutoSaveConfiguration(true)) and repeating the process. As expected, no stack trace occurred, supporting my belief that this is a bug.

It's entirely possible that I am using this library in an unintended manner, however if I understand what is happening correctly then I think this is an issue.

Founders do not have `ChannelPermission.SUBSCRIBER`

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Twitch added a new badge today for "Founders", which are the first 10 subscribers to an affiliate or the first 25 subscribers to a partner. The Founder badge replaces their subscriber badge in Twitch chat. https://help.twitch.tv/s/article/founders-badge

Twitch4j does not recognize this badge and does not properly parse Founders as subscribers.

Steps to Reproduce

  1. Listen on any chat in which Founders are chatting for ChannelMessageEvents.
  2. Check ChannelMessageEvent.getPermissions() on any Founder's messages.

Expected behavior:
ChannelMessageEvent.getPermissions().contains(ChannelPermission.SUBSCRIBER) is true.

Actual behavior:
ChannelMessageEvent.getPermissions().contains(ChannelPermission.SUBSCRIBER) is false.

Version affected:
Current develop branch (commit 798b778 ).

Credit to Sp0ck1 for discovering this bug.

Consider adding the users endpoint to TwitchKraken

Prerequisites

Description

The Helix users endpoint still does not contain the "created_at" property. This property is very useful when trying to combat channel spawn, by helping to identify newly created spam accounts.

Solutions

Although the Kraken endpoints are deprecated, consider adding the https://api.twitch.tv/kraken/users endpoint to TwitchKraken.java, so that the "created_at" property of users can be looked up.

Alternatives

Apparently there is currently no alternate way to get this information from the Twitch APIs

Feature List [v1]

OAuth Authentication

  • Twitch
  • StreamLabs - moving to new repository

Twitch REST Endpoints (Kraken) - Deprecated but still usable

  • Bits
  • Channel Feed #50
  • Channels
  • Chat
  • Clips
  • Collections
  • Communities (Released: 10.02.2017)
  • Games
  • Ingests
  • Search
  • Streams
  • Teams
  • Users
  • Videos
  • Uploading (for real)

New Twitch API (Helix)

  • Analytics
    • Game
    • Extension
  • Bits Leaderboard
  • Clips Creation
  • Clips
  • Games
    • Top Games
  • Streams
    • Metadata
  • Users
    • Follows
    • Updating User Description
    • Active Extension
    • Update Extension
  • Videos

Twitch PubSub

  • Bits
  • Commerce
  • Whispers
  • Subscriptions
  • Follows - Unofficial
  • Extension Broadcast System - Unofficial
  • Stream Status (Video Playback) - Unofficial
  • Moderation Action (from specified moderator in specified channel) - Unofficial

Twitch IRC (WebSocket)

  • Raids
  • Rituals
  • Chat Rooms
  • Subscriptions
  • Cheers (Bits)
  • /me interactions chat
  • /color changer
  • Moderation
    • Ban (with reason)
    • Timeout (with reason)
    • Slow mode
    • Sub mode
    • Follow mode
    • R9K mode
    • Emote Only mode
  • Channel Editor
    • Commercial
    • Host mode

Extension support (Soon)

  • JSON Web Token Authorization
  • PubSub (EBS - Extension Back-end Service)
  • Gradle / Maven Plugin provides utilites
  • Endpoints
    • Create Secret
    • Revoke Secret
    • Get Secrets
    • Live Channels with Active Extension
    • Set Required Config
    • Send PubSub Message (EBS)

WebSub (PubSub in Webhooks)

  • User Follows
  • Stream States (up/down)
  • User Data changed
  • Game Analytics

3rd Party

Streamlabs

  • Moving to new Repository
    • Users (Read)
    • Donations (Read, Create)
    • Custom Alerts (Create)

StreamElements

  • Planned

StreamTip

  • Planned

GameWisp

  • Planned

StreamPro

  • No API

Muxy.IO

  • No API

IRC-WS Improvements

Prerequisites

  • If this is a question/suggestion, I have already considered talking about it on Discord
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

There is a basics of IRC-WS in #15 & #16 - now they are need impove for Moderation, /me interactions, /color changeing, and Channel Editor changes - referencing changes to README.md

Steps to Reproduce

  1. Methods for casual users (Conventional bot with limits)
  • /me interaction chat brings text in colored - now will be like tmi.js's action(String channel, String message)
  • /color picker. For non Prime/Turbo subscription will be using by Twitch default colors in enum class or like a word. (first one will be simple)
  1. Methods for moderators (Give a bot, the green sword)
  • Banning/Timeouting user with/without reason
  • Chat mode:
    • Slow
    • Sub
    • Folow
    • Emote Only
    • R9K
  1. Methods for Channel Editor (Bot as Editor? If you know what you doing)
  • Commercials
  • Host mode
  1. Adding methods where they using API query for getting information about user information in chat via endpoint https://api.twitch.tv/kraken/users/<uid>/chat - where <uid> is user id. More info
  • it is known bot method returns boolean
  • increasing message bucket from 20 to 50 if is_known_bot is true

Expected behavior: Using referenced MessageInterface method, must be gave access more methods if aboved requirements was met.

Actual behavior: Gaving access for more methods, if aboved requirements was met, otherwise will thrown Custom exception stacktrace.

Stacktrace (if applicable): Custom stacktracing if aboved requirements will not met

Version affected: from feature\tmi branch, otherwise develop branch if #15 and #16 will merged there.

Additional Information

For the booth PR's #15 and #16 MessageInterface will be improved with chat interactions as Mod or Editor, and convectional daily usage elements (/color and /me). After #16 is finished, I will starting work for Improving steps above mentioned.

PubSub Cheering Event message not parsable

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Currently im using this piece of code to listen to PubSub events with a Spring Boot 2.1.5 application:

@Slf4j
@Component
@RequiredArgsConstructor
public class PubSubListener {

    @Value("${twitch.credentials.oauth}")
    private String oauth;

    @Value("${twitch.credentials.channelId}")
    private Long channelId;

    private final TwitchClient twitchClient;

    @PostConstruct
    public void test() {
        OAuth2Credential credential = new OAuth2Credential("oauth", oauth.split(":")[1]);
        twitchClient.getPubSub().listenForCheerEvents(credential, channelId);
        twitchClient.getPubSub().connect();
        Flux<CheerEvent> event = twitchClient.getPubSub().getEventManager().onEvent(CheerEvent.class);

        log.info("Subscribing to Cheer Events ...");

        event.subscribe(cheerEvent -> {
            log.info("{}", cheerEvent);
        });
    }
}

But suddenly i received a error message in the log:

2019-06-23 20:35:46.126  WARN 17264 --- [  ReadingThread] com.github.twitch4j.pubsub.TwitchPubSub  : PubSub: Unparsable Message: {"type":"MESSAGE","data":{"topic":"channel-bits-events-v1.118974949","message":"{\"data\":{\"user_name\":\"xxxxxx\",\"channel_name\":\"xxxxxxx\",\"user_id\":\"xxxxxxx\",\"channel_id\":\"xxxxxx\",\"time\":\"2019-06-23T18:35:44.443Z\",\"chat_message\":\"Cheer100 Cheer100 Cheer100 Cheer100\",\"bits_used\":400,\"total_bits_used\":2500,\"context\":\"cheer\",\"badge_entitlement\":null},\"version\":\"1.0\",\"message_type\":\"bits_event\",\"message_id\":\"083a3446-689d-5e0b-ab7a-xxxxxxxx\"}"}}
 - [com.fasterxml.jackson.databind.JsonMappingException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token

Steps to Reproduce

  1. Create a simple spring boot app through start.spring.io (standalone app should also do the same, just to create the same environment) (JDK12)
  2. Create this Bean (code above) or call this piece of code in the main method of the app
  3. Wait for a cheering event
  4. profit ???

Expected behavior:
I should get my cheering event as expected.

Actual behavior:
I'm getting this error message, nothing happens.

Stacktrace (if applicable):
Only this warn message occurs, no stacktrace:

2019-06-23 20:35:46.126  WARN 17264 --- [  ReadingThread] com.github.twitch4j.pubsub.TwitchPubSub  : PubSub: Unparsable Message: {"type":"MESSAGE","data":{"topic":"channel-bits-events-v1.118974949","message":"{\"data\":{\"user_name\":\"xxxxxx\",\"channel_name\":\"xxxxxxx\",\"user_id\":\"xxxxxxx\",\"channel_id\":\"xxxxxx\",\"time\":\"2019-06-23T18:35:44.443Z\",\"chat_message\":\"Cheer100 Cheer100 Cheer100 Cheer100\",\"bits_used\":400,\"total_bits_used\":2500,\"context\":\"cheer\",\"badge_entitlement\":null},\"version\":\"1.0\",\"message_type\":\"bits_event\",\"message_id\":\"083a3446-689d-5e0b-ab7a-xxxxxxxx\"}"}}
 - [com.fasterxml.jackson.databind.JsonMappingException: Cannot deserialize instance of `java.lang.String` out of START_OBJECT token

Version affected:
Latest 1.0.0-alpha.13

Additional Information

sg4e wrote on discord:

Is it possible this is a JDK-version issue?
Maybe a longshot, but I've found that code that was reliable in Java8 and below sometimes breaks in 9+, especially reflective code.

NEW Twitch API (Helix)

Description

Twitch release new API call name Helix. Kraken is now deprecated and will be removed 31 December 2018. Process will be discuss after TwitchCon

Steps to Reproduce

  1. Renamig/moving endpoints, models to kraken-named package.
  2. Reproduce new Twitch API with helix-named package
  3. Reproduce Dispatcher to Listening Webhooks <- link example webhook. Of course we will use Spring Framework.

Expected behavior: After 31 December 2018 the Kraken will be killed. Then new API will be apply.

Actual behavior: Twitch release incomplete API. Some endpoints is missing and still will be releasing slowly. More details below (see TwitchDev Road Map)

Stacktrace (if applicable): Stacktracing for Webhooks? We will see

Version affected: unknown

Additional Information

Possible bug: It seems that multiple chat-tags map to the EMOTE ChannelState

Prerequisites

Description

Possible bug: It seems that multiple chat-tags map to the EMOTE ChannelState
In:
IRCEventHandler.onChannelState

case "emote-only":
    states.put(ChannelStateEvent.ChannelState.EMOTE, v.equals("1"));

case "r9k":
    states.put(ChannelStateEvent.ChannelState.EMOTE, v.equals("1"));

case "subs-only":
    states.put(ChannelStateEvent.ChannelState.EMOTE, v.equals("1"));

Solutions

Should these have been ChannelState.R9K and ChannelState.SUBSCRIBERS respectively?

Twitch API v5 - Endpoint: Channel Feed

Description

Creating a channel feed endpoint and adding the following methods:

Endpoint Description
Get Multiple Feed Posts Gets posts from a specified channel feed.
Get Feed Post Gets a specified post from a specified channel feed.
Create Feed Post Creates a post in a specified channel feed. The content of the post is specified in the request body, with a required content parameter.
Delete Feed Post Deletes a specified post in a specified channel feed.
Create Reaction to a Feed Post Creates a reaction to a specified post in a specified channel feed. The reaction is specified by an emote value, which is either an ID (for example, “25” is Kappa) or the string “endorse” (which corresponds to a default face emote).
Delete Reaction to a Feed Post Deletes a specified reaction to a specified post in a specified channel feed. The reaction is specified by an emote ID (for example, “25” is Kappa) or the string “endorse” (which corresponds to a default face emote).
Get Feed Comments Gets all comments on a specified post in a specified channel feed.
Create Feed Comment Creates a comment to a specified post in a specified channel feed. The comment content can be specified either as a query-string parameter or in the request body (in x-www-form-urlencoded format).
Delete Feed Comment Deletes a specified comment on a specified post in a specified channel feed.
Create Reaction to a Feed Comment Creates a reaction to a specified comment on a specified post in a specified channel feed. The reaction is specified by an emote value, which is either an ID (for example, “25” is Kappa) or the string “endorse” (which corresponds to a default face emote).
Delete Reaction to a Feed Comment Deletes a reaction to a specified comment on a specified post in a specified channel feed. The reaction is specified by an emote value, which is either an ID (for example, “25” is Kappa) or the string “endorse” (which corresponds to a default face emote).

Additional Information

Link: https://dev.twitch.tv/docs/v5/reference/channel-feed/

Boolean variable mappings for ChannelPointsReward are incorrect

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

The boolean mapping inside the ChannelPointsReward class (and possibly other classes as well) doesn't seem to be working. This is probably because the variable inside the API is named is_enabled (See https://dev.twitch.tv/docs/pubsub and search for is_enabled on there) but the variable name inside the class is just enabled. I would expect ChannelPointsReward.enabled to be true because otherwise I could not receive that event.

This is likely due to the variables not starting with an is inside the POJO. Either the variables could be renamed or an annotation could be used to map the variables correctly. (Would do a PR for this if a fix is decided, I would personally use annotations here)

Steps to Reproduce

(Probably not very easy to replicate as you need to have an affiliate or partner account)

  1. Start up PubSub and listen for RewardRedeemedEvents and log those out
  2. Redeem a reward and look at the printed event

Expected behavior:
The boolean values are mapped correctly

Actual behavior:
All booleans that start with is in the API docs are not properly remapped and therefore appear as false. Example output:

RewardRedeemedEvent(super=ChannelPointsRedemptionEvent(timestamp=java.util.GregorianCalendar[time=1589148442413,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=143,lastRule=java.util.SimpleTimeZone[id=Europe/Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,startTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600000,endTimeMode=2]],firstDayOfWeek=2,minimalDaysInFirstWeek=4,ERA=1,YEAR=2020,MONTH=4,WEEK_OF_YEAR=20,WEEK_OF_MONTH=2,DAY_OF_MONTH=11,DAY_OF_YEAR=132,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=2,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=7,SECOND=22,MILLISECOND=413,ZONE_OFFSET=3600000,DST_OFFSET=3600000], redemption=ChannelPointsRedemption(id=4e018d46-5e99-42bf-b695-7e3dec2f3f3d, user=ChannelPointsUser(id=433891793, login=spaxbtw, displayName=spaxbtw), channelId=433891793, redeemedAt=2020-05-10T22:07:22.325142926Z, reward=ChannelPointsReward(id=662b073a-f9db-4efd-a890-74c575ce5e2f, channelId=433891793, title=Message, prompt=, cost=100, userInputRequired=false, subOnly=false, image=null, defaultImage=ChannelPointsReward.Image(url1x=https://static-cdn.jtvnw.net/custom-reward-images/default-1.png, url2x=https://static-cdn.jtvnw.net/custom-reward-images/default-2.png, url4x=https://static-cdn.jtvnw.net/custom-reward-images/default-4.png), backgroundColor=#FA1ED2, enabled=false, paused=false, inStock=false, maxPerStream=ChannelPointsReward.MaxPerStream(isEnabled=false, maxPerStream=0), shouldRedemptionsSkipRequestQueue=true), userInput=Dies hier ist eine Testnachricht, status=FULFILLED)))

Version affected:
1.0.0-alpha.19

Integration Tests

Description

  • Adding integration tests for all official/unofficial api endpoints.
  • Split Unit Tests and Integration Tests to run separately
  • Run integration test's for master frequently, regardlesss of builds (for notifications)

Additional Information

Integration tests are useful to test if any functionality is broken, especially since this api also provides access to unofficial endpoints (which can change without notice).

Support tags on Streams

Prerequisites

Description

Twitch streams have a list of tags. There exists an endpoint get those ( https://dev.twitch.tv/docs/api/reference/#get-all-stream-tags ). This is not yet implemented by Twitch4J.

See also: https://discuss.dev.twitch.tv/t/introducing-the-tags-api/19574

Steps to Reproduce


Expected behavior:

Actual behavior:

Stacktrace (if applicable):

Version affected:

Additional Information

Jar Runner

Description

As a Jar file can be use it for only chat monitoring purpose. Fetching messages into log file (logback.xml adjustments). First at all, the bot needs bot owner, when is impossible to get it via API (D4J have this solution). Using arguments parsing by JCommander (simple command line parser supporting POJO) we can define arguments, like:

  • Client id - --client-id or -c
  • Client Secret - --client-secret, --secret or -s
  • Bot token - --bot-token, --token or -t
  • Bot refresh token - --bot-refresh-token, --refresh or -r
  • Debug mode - --debug or -D

etc.

Steps to Reproduce

  1. Main Class will be called io.twitch4j.Twitch4J or com.github.twitch4j.Twitch4J as launcher application.
  2. Launcher will have stand-alone Jetty Server
  3. Logging for launching class will be adjusted in logback.xml file
  4. Session storage will be saving as memory [Map<String, ICredentials> (I know "Code Coverage")] or as File [Properties - similar like Map<K, V>]

Expected behavior: Launching will be like: java -Dfile.encoding=utf-8 -jar twitch4j.jar --c <clientID> -t <botToken> -r <botRefreshToken> -D

Actual behavior: Starting bot instance and Tomcat server.

Stacktrace (if applicable): Applicate stacktrace for separate logfile.

Version affected: LATEST

ChannelGoLiveEvent Triggering more than once

I recently updated to version 1.0.0-alpha.20 and am now having an issue where the ChannelGoLiveEvent is triggered more than once.

I have only been facing this issue after updating from 1.0.0-alpha.19, and it is not related to the Twitch API. It is nothing to do with streamers streams freezing, the event gets triggered up to 10 times in the matter of a few seconds for one streamer, and even triggers after they end stream sometimes.

Could this be fixed? It is also nothing to do with my code, as I have not changed any of that stuff for about a year, and have never had a problem before. Thanks

Error with Helix getSubscriptions()

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

I'm trying to get channel subscriptions with helix:

SubscriptionList subList = twitchClient.getHelix().getSubscriptions(
                myAccessToken,
                channelId,
                null,
                null,
                100
        ).execute();

but i getting this error:

Caused by: feign.FeignException: Cannot deserialize value of type `java.lang.Integer` from String "ByterbrodTV": not a valid Integer value

Steps to Reproduce

  1. Find partner channel.
  2. Get access token for it.
  3. Try to get list of subscribers with helix

Expected behavior:
I expect getting list of subscriptions

Actual behavior:
InvalidFormatException

Stacktrace (if applicable):

Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Integer` from String "ByterbrodTV": not a valid Integer value
 at [Source: java.io.BufferedReader@63502b8e; line: 1, column: 175] (through reference chain: com.github.twitch4j.helix.domain.SubscriptionList["data"]->java.util.ArrayList[0]->com.github.twitch4j.helix.domain.Subscription["user_name"])

Version affected:

I trying this on 1.0.0-alpha.11 and 1.0.0-alpha.14

Additional Information

I think userName must be String in this case
package com.github.twitch4j.helix.domain;
image

P.S.

  1. There is good accesstoken. I trying to do it manually - it works.
  2. I also get working with kraken but kraken is not stable for me and sometimes throwing me time-out and no fallback exception.

Message Interface Performance (PubSub)

Prerequisites

  • If this is a question/suggestion, I have already considered talking about it on Discord
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Let me explain. PubSub have chat_moderator_actions topic. When it isn't documented yet. Actually using IRC will make a mess in code. I plannin use IRC only for:

  • message monitoring (booth direction) and
  • sending message / commands to channel.

In PubSub we can setup:

  • video-playback.- stream is starting, ending and view counter if stream is online
  • chat_moderator_actions.<mod_user_id>.<channel_id> - chat moderation logs
  • channel-bits-events-v1.<channel_id>
  • channel-subscribe-events-v1.<channel_id>
  • whispers.<user_id>

Steps to Reproduce

  1. Rewrite PubSub
  2. Write test units for PubSub

...

Expected behavior: IRC synchronized with PubSub actions

Actual behavior: Synchronizing Message Interface

Stacktrace (if applicable):

  • Warnings for: Lost connection from PubSub and reconnect it.
  • Errors for: wrong oauth key, missing required scope for specified topics

Version affected: LATEST

Additional Information

last 3 topics is on documentation: https://dev.twitch.tv/docs/PubSub#available-topics
chat_moderator_actions: https://discuss.dev.twitch.tv/t/in-line-broadcaster-chat-mod-logs/7281
video-playback: https://discuss.dev.twitch.tv/t/introducing-the-twitch-pubsub-system/6847/15

Twitch API v5 - Endpoint: Chat

Description

Creating a chat endpoint and adding the following methods:

Endpoint Description
Get Chat Badges by Channel Gets a list of badges that can be used in chat for a specified channel.
Get Chat Emoticons by Set Gets all chat emoticons (not including their images) in one or more specified sets. If no set is specified, all chat emoticons are returned.
Get All Chat Emoticons Gets all chat emoticons (including their images).

Additional Information

Link: https://dev.twitch.tv/docs/v5/reference/chat/

twitch stream key

i wonder if its possible to retrieve stream key.. or if u could add the possibility to do that

Cannot clear chat

Prerequisites

  • If this is a question/suggestion, I have already considered talking about it on Discord
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

I tried to make a command that allows specific users to clear the chat if they're not moderators but instead of clearing the chat I just received a stack trace. I used the clearChat() method of the event to clear the chat.

Steps to Reproduce

  1. Use clearChat() on ChannelMessageEvent

Expected behavior: [What was supposed to happen] Bot should've cleared the chat

Actual behavior: [What actually happened] Bot did nothing

Stacktrace (if applicable): [link to the stacktrace] https://paste.md-5.net/pajevolile.avrasm

Version affected: [The version/commit you are using] cce583f

Additional Information

[Any other information that may be able to help me with the problem]

ChannelGoLiveEvent doesn't trigger everytime

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

I don't know exactly why, but ChannelGoLiveEvent doesn't trigger everytime. Sometimes it works 3 days without any problem, and then nothing. However, ChannelGoOfflineEvent works perfectly.
It seems to happen everytime a replay is started on the channel.
Here is the code »
twitchClient.getEventManager().onEvent(ChannelGoOfflineEvent.class).subscribe((channelGoOfflineEvent) -> {/*insert code*/});

Before you ask, no, there isn't any errors, and I already tried to put only a sysout and it does not trigger.

Steps to Reproduce

  1. Add the code line in a method which is triggered at programs startup.
  2. Don't forget to add twitchClient.getClientHelper().enableStreamEventListener("your_channel"); before registering any events related to live events.
  3. Launch a live, the event should trigger as excepted.
  4. Launch a replay, and wait until it finishes or stop it.
  5. Launch a live, the event shouldn't trigger.
  6. This is optional, but you can try restarting the program, relaunch the live, and it should work again.

Expected behavior:

The event was supposed to trigger.
Actual behavior:

The event isn't triggered.

Version affected:

1.0.0-alpha.11

Twitch API v5 - Endpoint: Communities

Description

Creating a community endpoint and adding the following methods:

Endpoint Description
Get Community by Name Gets a specified community.
Get Community by ID Gets aspecified community.
Create Community Creates a community.
Update Community Updates a specified community.
Get Top Communities Gets the top communities by viewer count.
Get Community Banned Users Gets a list of banned users for a specified community.
Ban Community User Adds a specified user to the ban list of a specified community.
Un-Ban Community User Deletes a specified user from the ban list of a specified community.
Create Community Avatar Image Adds a specified image as the avatar of a specified community.
Delete Community Avatar Image Deletes the avatar image of a specified community.
Create Community Cover Image Adds a specified image as the cover image of a specified community.
Delete Community Cover Image Deletes the cover image of a specified community.
Get Community Moderators Gets a list of moderators of a specified community.
Add Community Moderator Adds a specified user to the list of moderators of a specified community.
Delete Community Moderator Deletes a specified user from the list of moderators of a specified community.
Get Community Permissions Gets a list of actions users can perform in a specified community.
Report Community Violation Reports a specified channel for violating the rules of a specified community.
Get Community Timed-Out Users Gets a list of users who are timed out in a specified community.
Add Community Timed-Out User Adds a specified user to the timeout list of a specified community.
Delete Community Timed-Out User Deletes a specified user from the timeout list of a specified community.

Additional Information

Link: https://dev.twitch.tv/docs/v5/reference/communities/

Manual resub message

Description

Adding a method so that a resub message can be send to subbed channels.

Additional Information

Bot needs clear-text credentials and fetch a cookie to use those api methods.

Method:

POST https://api.twitch.tv/api/channels/CHANNEL_NAME_HERE/use_chat_notification_token

token_id: 1234567
custom_message: Your message here

The token ID is available in the https://api.twitch.tv/api/channels/CHANNEL_NAME_HERE/chat_properties endpoint (with auth using the cookie from the account).

Unable to find API's Class using Maven dependencies from Intellij IDEA

Prerequisites

Description

When I try to use for example the Class TwitchClient, it said of she's not found.

Solutions

Get help for the API work in Maven.

Alternatives

We're writting code with Twitch API, and it is not finding the Classes.

Additional context

KrakenTeam model is missing team members (users)

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

The "get team" API endpoint supports an array of users who belong to that team (see https://dev.twitch.tv/docs/v5/reference/teams/#get-team for details), but the current implementation in Twitch4J does not have that information.

To Fix

The KrakenTeam model needs to have a List<KrakenUser> users added to it to support the missing information.

Version affected:
1.0.0-alpha16

Additional Information

I have fixed this locally for me and can submit a Pull Request.

Twitch API v5 - Endpoint: Scheduled Events

Description

Creating methods for the new event feature (no official api methods yet):

Endpoint Description
Get Scheduled Channel Events Gets scheduled events for a specified channel

Additional Information

Unofficial endpoints to fetch channel events https://api.twitch.tv/v5/channels/{channelId}/events (no auth required)

Android compatibility

Hi,

Your twitch4j seems very good, very well written, etc... but unfortunately you are using a lot of libraries and Java 8 adding lot of difficulties to make it compatible with Android, that's a pity.

Do you think it could be possible to improve its compatibility ?

JavaDoc

Description

Let Travis CI generate the javadocs and commit them to a github pages branch.

Subtasks

  • Add JavaDocs generation
  • GitHub Pages for JavaDocs
  • Add Link from README

StreamEventListener not always working

I am using Twitch4J for a Live Alerts feature of my Discord Bots. I have enabled the StreamEventListener for all of the streamer's names, and when the code runs, it adds them all with a 2-second wait in between each one.

This does not always work, and my ChannelGoLiveEvent is not always triggered when someone goes live. It does work sometimes, but not other times.

Expected behavior:
Event to be triggered when someone goes live

Actual behavior:
Event is not always triggered

Version affected:
1.0.0-alpha.19

All Thread creation should use a ScheduledExecutor and be customizeable

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

Threading is uncontrollable, and not done with Java best practices in mind. Currently, Threads are running forever and slept as opposed to scheduled and executed and then destroyed. Also, I have no ability to customize when these threads are run or to have them participate in Thread Pool my application has already created.

Solutions

Use ScheduledThreadPoolExecutor everywhere (PubSub, ClientHelper etc)
Allow us to provide our own Executor
Allow us to configure how often all tasks are ran

Out of memory on 1.0.0-alpha.15 using twtich chat

Here is what Eclipse Memory Analyzer says:

image

I will not provide a precise reproducer for the issue, but I just want you to know about the bug existence.

The bug occurs when you have joined a lot of chats(30+ in my case) and then some of them goes offline. Heap size starts increasing:

image

TwitchClientHelper allow more than 100 channels to be added for GoLiveEvent

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

As my application is growing I've noticed that it now has stopped working since I'm making too many requests. I'm using the ChannelGoLiveEvent and I need more than 100 channels to listen to. Just over 500 to be exact.

Solutions

If I've done twitchClient.getClientHelper().enableStreamEventListener("channel"); more than 100 times, then split the list listenForGoLive and inside the Client Helper send the request multiple times with the splitted lists, to support more than 100 channels.

Alternatives

I've tried using the TwitchClientHelper class to try to replicate the function and modify it myself, but I can't seem to make it work. However I am sure this is due to the limits of my Java knowledge. I'm sure anyone with more knowledge would be able to do this quite easy.

Additional context

A NullPointerException is thrown instead of a more specific exception for some methods when incorrect authentication is provided

Prerequisites

  • If this is a question/suggestion, I have already considered discuss it on Discord Server
  • This issue specifically has something to do with Twitch4J
  • I have attempted to look for similar issues already

Description

At least twitchClient.getHelix().replaceStreamTags(...).execute() generates a NullPointerException when a bogus auth token is provided instead of a com.github.twitch4j.common.exception.UnauthorizedException like the graceful error handling is intended to throw.

Steps to Reproduce

         // chat credential
        OAuth2Credential credential = new OAuth2Credential("twitch", "bogustoken");

        // twitch client
        twitchClient = TwitchClientBuilder.builder()
                .withClientId(API_CLIENT_ID)
                .withClientSecret(API_CLIENT_SECRET)
                .withEnableChat(true)
                .withEnableHelix(true)
                .withChatAccount(credential)
                .build();
        twitchClient.getHelix().replaceStreamTags("bogustoken", 73758417L, new ArrayList<>()).execute();

Expected behavior:
com.github.twitch4j.common.exception.UnauthorizedException

Actual behavior:
java.lang.NullPointerException

Version affected:
8912db2

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.