Skip to content

Commit

Permalink
增加参数
Browse files Browse the repository at this point in the history
  • Loading branch information
907739769 committed Jun 14, 2024
1 parent 41343de commit 5112a76
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ ENV syncUrl=""
ENV syncDir=""
ENV tgToken=""
ENV tgUserId=""
ENV tgUserName="bot"
ENV logLevel=""
ENV JAVA_OPTS="-Xms32m -Xmx512m"
ENTRYPOINT ["sh","-c","java -jar $JAVA_OPTS -XX:+UseG1GC -XX:+OptimizeStringConcat -XX:+PrintGCDetails -Xloggc:/log/gc.log -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/log /xiaoyasync.jar"]
7 changes: 7 additions & 0 deletions src/main/java/cn/jackding/xiaoyasync/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class Config {

public static String tgUserId;

public static String tgUserName;

@Value("${tgToken}")
public void setTgToken(String tgToken) {
Config.tgToken = tgToken;
Expand All @@ -25,4 +27,9 @@ public void setTgUserId(String tgUserId) {
Config.tgUserId = tgUserId;
}

@Value("${tgUserName:bot}")
public void setTgUserName(String tgUserName) {
Config.tgUserName = tgUserName;
}

}
9 changes: 2 additions & 7 deletions src/main/java/cn/jackding/xiaoyasync/tgbot/SyncBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ public class SyncBot extends AbilityBot {

private final ResponseHandler responseHandler = new ResponseHandler(sender, db);

public SyncBot() {
super(Config.tgToken, "bot");
}

public SyncBot(DefaultBotOptions options) {
super(Config.tgToken, "bot", options);
super(Config.tgToken, Config.tgUserName, options);
}

@Override
Expand Down Expand Up @@ -76,8 +72,7 @@ public Ability syncDir() {
SyncService syncService = (SyncService) SpringContextUtil.getBean("syncService");
syncService.syncFiles(parameter);
})
.reply((bot, upd) -> responseHandler.replyToSyncDdir(getChatId(upd), upd.getMessage().getText(), upd.getMessage().getMessageId()), Flag.REPLY//回复
, upd -> upd.getMessage().getReplyToMessage().getFrom().getUserName().equalsIgnoreCase(getBotUsername()),//回复的是机器人
.reply((bot, upd) -> responseHandler.replyToSyncDdir(getChatId(upd), upd.getMessage().getText(), upd.getMessage().getMessageId()), Flag.REPLY,//回复
upd -> upd.getMessage().getReplyToMessage().hasText(), upd -> upd.getMessage().getReplyToMessage().getText().equals("请输入路径")//回复的是上面的问题
)
.build();
Expand Down

0 comments on commit 5112a76

Please sign in to comment.