-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add single line comment small changes
- Loading branch information
shandiankulishe
committed
Apr 23, 2022
1 parent
df40394
commit 0196e26
Showing
12 changed files
with
172 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/glous/kleebot/services/impl/SyncService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package glous.kleebot.services.impl; | ||
|
||
import glous.kleebot.KleeBot; | ||
import glous.kleebot.cache.CacheFactory; | ||
import glous.kleebot.features.pixiv.PixivAPI; | ||
import glous.kleebot.services.GroupService; | ||
import net.mamoe.mirai.event.events.GroupMessageEvent; | ||
import net.mamoe.mirai.message.data.At; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
|
||
public class SyncService extends GroupService { | ||
@Override | ||
public boolean process(GroupMessageEvent event) { | ||
return event.getMessage().serializeToMiraiCode().startsWith(new At(KleeBot.config.getBotAccount())+" sync "); | ||
} | ||
|
||
@Override | ||
public boolean execute(GroupMessageEvent event) throws Exception { | ||
String message=event.getMessage().serializeToMiraiCode(); | ||
String[] args=message.substring(message.indexOf("sync")+5).split(" "); | ||
if (args[0].equals("info")){ | ||
//pixiv rank sync info | ||
PixivAPI api=new PixivAPI(KleeBot.config.getProxyHost(),KleeBot.config.getProxyPort()); | ||
HashMap<Integer, HashMap<String,String>> daily=api.getDailyRanking(false); | ||
HashMap<Integer,HashMap<String,String>> weekly=api.getWeeklyRanking(false); | ||
HashMap<Integer,HashMap<String,String>> monthly=api.getMonthlyRanking(false); | ||
StringBuilder builder=new StringBuilder(); | ||
builder.append("Pixiv Synchronization Info:\n"); | ||
for (HashMap<String, String> artwork : | ||
daily.values()) { | ||
String syncInfo= | ||
""" | ||
%s\040""".formatted(artwork.get("title")); | ||
builder.append(syncInfo); | ||
if (CacheFactory.getCache(artwork.get("imageUrl"))==null) | ||
builder.append("\uD83D\uDD34\n"); | ||
else | ||
builder.append("\uD83D\uDFE2\n"); | ||
} | ||
for (HashMap<String, String> artwork : | ||
weekly.values()) { | ||
String syncInfo= | ||
""" | ||
%s\040""".formatted(artwork.get("title")); | ||
builder.append(syncInfo); | ||
if (CacheFactory.getCache(artwork.get("imageUrl"))==null) | ||
builder.append("\uD83D\uDD34\n"); | ||
else | ||
builder.append("\uD83D\uDFE2\n"); | ||
} | ||
for (HashMap<String, String> artwork : | ||
monthly.values()) { | ||
String syncInfo= | ||
""" | ||
%s\040""".formatted(artwork.get("title")); | ||
builder.append(syncInfo); | ||
if (CacheFactory.getCache(artwork.get("imageUrl"))==null) | ||
builder.append("\uD83D\uDD34\n"); | ||
else | ||
builder.append("\uD83D\uDFE2\n"); | ||
} | ||
builder.append("END"); | ||
System.out.println(builder.toString()); | ||
sendMessage(builder.toString(),event); | ||
return true ; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.
0196e26
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
kleebot – ./
kleebot-git-master-youfantan.vercel.app
kleebot-youfantan.vercel.app