Address PR #15 round 2: fail-closed admin guard, sync init, error reporting
1. /refresh now fail-closed: rejects all if ADMIN_CHAT_ID unset or invalid 2. Initial pair cache fill is synchronous — bot waits before accepting queries 3. /refresh reports failure when API fetch fails instead of always saying success Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -23,10 +23,12 @@ func OnGetTopFundingFee(context telebot.Context) error {
|
||||
}
|
||||
|
||||
func OnRefreshPairCache(context telebot.Context) error {
|
||||
adminID, _ := strconv.ParseInt(os.Getenv(key.AdminChatID), 10, 64)
|
||||
if adminID != 0 && context.Sender().ID != adminID {
|
||||
adminID, err := strconv.ParseInt(os.Getenv(key.AdminChatID), 10, 64)
|
||||
if err != nil || adminID == 0 || context.Sender().ID != adminID {
|
||||
return nil
|
||||
}
|
||||
data.Market.RefreshTradingPairCache()
|
||||
if err := data.Market.RefreshTradingPairCache(); err != nil {
|
||||
return chat.ReplyMessage(context, "Failed to refresh trading pair cache")
|
||||
}
|
||||
return chat.ReplyMessage(context, "Trading pair cache refreshed")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user