gikkman / java-twirk Goto Github PK
View Code? Open in Web Editor NEWSmall, basic library for communication via the Twitch chat. Java 8 compatible
License: MIT License
Small, basic library for communication via the Twitch chat. Java 8 compatible
License: MIT License
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,.
This would be very useful as i need a bot the needs to been in a handful of channels, thanks
Expose followers-only
tag in RoomState
- https://dev.twitch.tv/docs/irc/tags#roomstate-twitch-tags
When i use getReason(), its return null string.
The # is needed for channel actions, so, at least in my opinion, it should be added to the channel name in the background, so that you don't always have to remember it.
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
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.
Currently the library uses System.out.println
for 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.
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)
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)
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>
.
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.
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.
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.
Recently stumbled on this undocumented api. May prove useful for parsing out badges.
pls add a option to use Channel Points
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.
Does this library support 3rd party emote services like FrankerFaceZ, BetterTwitchTV, 7TV, etc.?
Well this library sound great...
But i need support for new system of subs, plan subs prime,1000,2000,3000.
Expose emote-only
tag in RoomState
- https://dev.twitch.tv/docs/irc/tags#roomstate-twitch-tags
I know there is an example but I would like to see a full api discrimination each function ๐
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
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.
Twitch plans to deprecate some message tags: subscriber
, turbo
and user-type
. They want people to use badges
instead.
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)
Is there a way that you can add a sub 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.
Some observations from using this simple and cool library for a few hours:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.