Coder Social home page Coder Social logo

java-twirk's People

Contributors

doc94 avatar e3ndr avatar gikkman avatar j4ckofalltrades avatar jcog avatar mrhighside avatar nihaals 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

Watchers

 avatar  avatar  avatar  avatar

java-twirk's Issues

Number Format Exception when using modified emotes

Twitch now allows modifying emotes using channel points. But if someone uses a modified emote, the library throws an exception:

IN  @badge-info=subscriber/31;badges=broadcaster/1,subscriber/12;color=#FF69B4;display-name=Gikkman;emote-only=1;emotes=832830_BW:0-11;flags=;id=1f700ce1-df69-4482-a839-d65e68cf34fc;mod=0;room-id=27658385;subscriber=1;tmi-sent-ts=1578423230564;turbo=0;user-id=27658385;user-type= :[email protected] PRIVMSG #gikkman :gikkmaLUL_BW
Error in handling the incomming Irc Message
java.lang.NumberFormatException: For input string: "832830_BW"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Integer.parseInt(Integer.java:615)
	at com.gikk.twirk.types.emote.EmoteParser.finalizeEmote(EmoteParser.java:78)
	at com.gikk.twirk.types.emote.EmoteParser.parseEmotes(EmoteParser.java:68)
	at com.gikk.twirk.types.twitchMessage.DefaultTwitchMessageBuilder.build(DefaultTwitchMessageBuilder.java:36)
	at com.gikk.twirk.Twirk.incommingMessage(Twirk.java:435)
	at com.gikk.twirk.InputThread.run(InputThread.java:43)

This can probably be fixed pretty quickly by making the emoteID a String instead of an Integer, and not do the integer parsing, but that'd break backwards compatability.

Instead, I suggest keeping it as is, and cutting by the _ if it is present, and then maybe expose the modified as "modifiedId" or such,.

Ban Reason

When i use getReason(), its return null string.

TwitchUser getColor

Whenever I use the sender.getColor() method inside of onPrivMsg(TwitchUser sender, TwitchMessage message), it returns a number that is not a valid hex value

Automatically cast channel name to lower-case

If the channel name isn't in lower case, Twirk will connect to a ghost channel, which might fool a user that something is wrong. This is a valid IRC behavior, but since Twitch has all their channels in lowercase, we might as well lower-case the channel name automatically.

Add ability to set custom logger methods

Currently the library uses System.out.printlnfor log messages, which isn't ideal. Preferably, we'd like to use loggers such as log4j, logback or the similar.

Since I really want the library to stick to 0 dependencies, I plan on exposing a way of setting custom method references to use for logging. For example:

twirkBuilder.setInfoLogger(System.out::println)
twirkBuilder.setErrorLogger(System.err::println)

This will allow people to pass whatever logger methods they want, and still maintaining 0 dependencies on the library. Users of the library can simply pass logger::info and the likes to the different setXXXLogger method at instance creation.

NumberFormatException on joining a channel with subscription

Error in handling the incoming Irc Message
For input string: "568bb8c9-cb3a-4a15-97eb-79288caa66c1"
java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67)
java.base/java.lang.Integer.parseInt(Integer.java:660)
java.base/java.lang.Integer.parseInt(Integer.java:778)
com.gikk.twirk.types.AbstractTwitchUserFields.parseEmoteSets(AbstractTwitchUserFields.java:77)
com.gikk.twirk.types.AbstractTwitchUserFields.parseUserProperties(AbstractTwitchUserFields.java:61)
com.gikk.twirk.types.users.DefaultUserstateBuilder.build(DefaultUserstateBuilder.java:10)
com.gikk.twirk.Twirk.incommingMessage(Twirk.java:528)
com.gikk.twirk.InputThread.run(InputThread.java:43)

Handle RECONNECT

IN  :tmi.twitch.tv RECONNECT
Error in handling the incomming Irc Message
java.lang.StringIndexOutOfBoundsException: String index out of range: 24
	at java.lang.String.charAt(String.java:658)
	at com.gikk.twirk.types.twitchMessage.GikkDefault_TwitchMessageBuilder.parseWithoutTag(GikkDefault_TwitchMessageBuilder.java:81)
	at com.gikk.twirk.types.twitchMessage.GikkDefault_TwitchMessageBuilder.build(GikkDefault_TwitchMessageBuilder.java:24)
	at com.gikk.twirk.Twirk.incommingMessage(Twirk.java:442)
	at com.gikk.twirk.InputThread.run(InputThread.java:43)

CheerImpl.getImageURL does not return the correct URL

Hey there!

public String getImageURL(CheerTheme theme, CheerType type, CheerSize size) from CheerImpl.java does not return a valid URL.

For instance,

val cheer = new CheerImpl(100, "TEST")
val cheerType = CheerType.STATIC
val cheerTheme = CheerTheme.LIGHT
val cheerSize = CheerSize.TINY

cheer.getImageURL(cheerTheme, cheerType, cheerSize)

returns the following string: static-cdn.jtvnw.net/bits/<theme>/<type>/<color>/<size>/light/static/purple/1.

The issue, according to the method getImageURL , stems from the value of ROOT_URL which should be static-cdn.jtvnw.net/bits instead of static-cdn.jtvnw.net/bits/<theme>/<type>/<color>/<size>.

StreamLabs interface

I'm not sure how feasible this is because I don't really know how all this works but I think it would be helpful to have this library be able to interact with StreamLabs. For example detecting donations through StreamLabs.

Moderators set not available

public Set<String> getModsOnline() from Twirk.java returning empty set, even if moderators present on channel and typing in chat.
Although public Set<String> getUsersOnline() is working properly.

Allow custom PING interval

Twitch recommends you ping them once every >5 minutes IF you haven't seen a message from them. While this is fine for the most part, sometimes Twitch is unstable and connections are dropped. This takes up to 5 minutes to detect though, so it would be neat to let users of the library set a custom timeout IF they want to.

Chat not updating in real time

When trying to use the onAnything event, the event is only ran when previous old messages are loaded in on application start. Any messages that are sent after twirk has connected don't go through.

Whispers seem to be picked up fine when using onPrivMsg, it just doesn't pick up general chats.

This is the code I currently have:

static final Twirk twirk = new TwirkBuilder("XXXXXX", "XXXXXX", "oauth:XXXXXXX").setVerboseMode(true).build();

public static void main(String[] args) {
        try {
            twirk.connect();
            System.out.println("Connected to Twitch chat.");
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        twirk.addIrcListener(new TwirkListener() {
            @Override
            public void onAnything(String unformatedMessage) {
                System.out.println("Message received.");
            }
        });
}

I get a bunch of "Message received." logs when the application starts, but no more logs when new messages are sent in chat. I've also noticed that messages sent using twirk.channelMessage() don't show up on my page until chat is refreshed. Has something changed in Twitch recently or could it be something to do with my bot account like a setting that needs to be changed?

This happens when using the latest from the repo, not a JAR release.

Thanks.

add isOwner to TwitchUser

I'm liking the library, but one thing I've noticed coming into this is that isMod doesn't cover the channel
so I'm having to do

if (sender.isMod || sender.userType == USER_TYPE.OWNER) {
                twirk.channelMessage("Mods Only Message")
}

A handy isOwner would be a nice to have on the TwitchUser interface

Calling connect after previously calling close fails

After creating a Twirk instance, calling connect(), close(), connect(), results in:

java.net.SocketException: Socket is closed

This seems to be because in the 4.0 rewrite, createResources no longer creates a new socket and releaseResources does still close the socket.

NumberFormatException on bit emotes

I got a report on Discord:

The issue seems to occur when people enter a bit emote, but I don't got more details at the moment.

java.lang.NumberFormatException: For input string: "emotesv2"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at com.gikk.twirk.types.emote.EmoteParserImpl.finalizeEmote(EmoteParserImpl.java:75)
    at com.gikk.twirk.types.emote.EmoteParserImpl.parseEmotes(EmoteParserImpl.java:64)
    at com.gikk.twirk.types.twitchMessage.DefaultTwitchMessageBuilder.build(DefaultTwitchMessageBuilder.java:37)
    at com.gikk.twirk.Twirk.incommingMessage(Twirk.java:461)
    at com.gikk.twirk.InputThread.run(InputThread.java:43)

VIP is not a defined USER_TYPE

There doesn't appear to be a way to determine if a user is a VIP. This seems to me like it would fit in with USER_TYPE with a value below MOD since a user can't be both a mod and vip at the same time.

Observations (Catch listener handler exceptions separately from IO exceptions)

Some observations from using this simple and cool library for a few hours:

  • I spent a bit of time trying to figure out the correct token to login, manually doing authflows as per twitch documentation, but only after I saw the link in TwirkBuilder class to link, that does this for me. Would be really helpful to put this link into readme :-D
  • When my listener method throws exception, your library propagates it as a problem with parsing IRC messages.

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.