This project is inspired by the afreecatv-chat-crawler project.
I would like to express my gratitude to the original creator for their inspiration and contributions.
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.lede-dev:afreecatv-chat-crawler-java:{version}'
}
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.lede-dev</groupId>
<artifactId>afreecatv-chat-crawler-java</artifactId>
<version>Tag</version>
</dependency>
First, we create an instance of AfreecaTvChatCrawler. There are two ways to create an instance.
- Use AfreecaTV live broadcast URL
AfreecaTvChatCrawler crawler = new AfreecaTvChatCrawler("play.afreecatv.com/lilpa0309/263127556");
or
boolean autoReconnect = true;
long autoReconnectDelayMilliSeconds = 1000;
AfreecaTvChatCrawler crawler = new AfreecaTvChatCrawler(
"play.afreecatv.com/lilpa0309/263127556", autoReconnect, autoReconnectDelayMilliSeconds);
- Use AfreecaTV Broadcaster ID and Number
AfreecaTvChatCrawler crawler = new AfreecaTvChatCrawler("lilpa0309", 263127556);
or
AfreecaTvChatCrawler crawler = new AfreecaTvChatCrawler("lilpa0309", "263127556");
Next, register the AfreecaTvMessageReceiveEvent to handle message reception.
crawler.registerMessageReceiveEvent(new AfreecaTvMessageReceiveEvent() {
@Override
public void onMessageReceive(@NotNull AccMessage message) {
String.format("%s[%s] : %s",
message.getSenderNickname(), message.getSenderId(), message.getMessage());
}
});
Once all configurations are complete, you can start the crawler.
crawler.connect();
That's it! Here are a few points to keep in mind when using it.
- If the AfreecaTV broadcaster is not live, the crawler won't be able to connect to the broadcast.
- Message reception operates in separate threads for each crawler. Be sure to use thread synchronization carefully.