Fix scraping workflows subscriptions bot and recycle bin

This commit is contained in:
ShukeBta
2026-06-17 19:48:17 +08:00
parent 91afbe54a2
commit 850d3db811
43 changed files with 2782 additions and 76 deletions
+43 -2
View File
@@ -149,8 +149,40 @@ func TestRegisterTelegramBotCommands(t *testing.T) {
}
}
func TestDeleteTelegramWebhookBeforePolling(t *testing.T) {
var gotPath string
var payload map[string]any
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotPath = r.URL.Path
if err := json.NewDecoder(r.Body).Decode(&payload); err != nil {
t.Fatalf("decode payload: %v", err)
}
_, _ = w.Write([]byte(`{"ok":true}`))
}))
defer server.Close()
err := deleteTelegramWebhook(t.Context(), map[string]string{
"bot_token": "123456:ABC",
"api_base_url": server.URL,
})
if err != nil {
t.Fatal(err)
}
if gotPath != "/bot123456:ABC/deleteWebhook" {
t.Fatalf("path = %q", gotPath)
}
if got := payload["drop_pending_updates"]; got != false {
t.Fatalf("drop_pending_updates = %#v, want false", got)
}
}
func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) {
privateNames := telegramCommandNames(telegramPrivateBotCommandMenu())
for _, required := range []string{"setname", "setpass"} {
if !privateNames[required] {
t.Fatalf("private menu should include %s", required)
}
}
for _, hiddenAlias := range []string{"myinfo", "count"} {
if privateNames[hiddenAlias] {
t.Fatalf("private menu should hide compatibility alias %s", hiddenAlias)
@@ -173,12 +205,12 @@ func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) {
}
adminCommands := telegramAdminBotCommandMenu()
adminNames := telegramCommandNames(adminCommands)
for _, required := range []string{"users", "status", "cleanup_mode", "cleanup_rule"} {
for _, required := range []string{"users", "status", "cleanup_mode", "cleanup_rule", "ucr", "uinfo", "rmemby", "only_rm_record", "renewall", "userip", "auditip", "auditdevice", "auditclient", "udeviceid", "syncunbound", "syncgroupm", "check_ex", "deleted", "embyadmin", "banall", "unbanall", "prouser", "revuser", "embylibs_blockall", "embylibs_unblockall", "proadmin", "revadmin", "backup_db", "restore_from_db"} {
if !adminNames[required] {
t.Fatalf("admin menu should include %s", required)
}
}
for _, hiddenAlias := range []string{"myinfo", "count"} {
for _, hiddenAlias := range []string{"myinfo", "count", "low_activity", "urm", "only_rm_emby", "extraembylibs_blockall", "extraembylibs_unblockall"} {
if adminNames[hiddenAlias] {
t.Fatalf("admin menu should hide compatibility alias %s", hiddenAlias)
}
@@ -188,6 +220,15 @@ func TestTelegramCommandMenusSeparateGroupAndAdminCommands(t *testing.T) {
t.Fatalf("admin menu command %s should use native Mgo wording: %q", command.Command, command.Description)
}
}
help := telegramMgoAdminCommandHelp()
for _, want := range []string{"用户:", "审计:", "清理:", "权限:", "运维:"} {
if !strings.Contains(help, want) {
t.Fatalf("mgo admin help should include category %q in %q", want, help)
}
}
if strings.Contains(help, "/setpass") {
t.Fatalf("mgo admin help should not include user self-service command /setpass")
}
}
func telegramCommandNames(commands []telegramBotCommand) map[string]bool {