changed verifier bot to marksbot

This commit is contained in:
onysd 2026-08-04 03:22:46 +03:00
parent 6ade34970c
commit fa5cfaf14d
16 changed files with 302 additions and 30 deletions

View file

@ -0,0 +1,55 @@
package botverification
import (
"context"
"errors"
"fmt"
"telesrv/internal/branding"
"telesrv/internal/domain"
)
// SeedDefaultVerifier idempotently grants @marksbot (domain.VerifierBotUserID)
// verifier status on first boot, using a custom-emoji icon the ordinary
// sticker-seed import already writes (domain.VerifierBotDefaultIconDocumentID)
// -- so the reference third-party verifier has something to demonstrate right
// away instead of an empty icon catalogue and a bot that can only explain
// itself.
//
// Runs at most once: if a bot_verifier_settings row for @marksbot already
// exists -- granted by this seed on a previous boot, or hand-configured by an
// operator who pointed it at a different icon/company -- it is left
// completely untouched. This must never overwrite an operator's own decision
// about their own verifier.
// Returns true if it actually granted verifier status.
func (s *Service) SeedDefaultVerifier(ctx context.Context) (bool, error) {
if s == nil || !s.enabled {
return false, nil
}
if _, err := s.VerifierSettings(ctx, domain.VerifierBotUserID); err == nil {
return false, nil
} else if !errors.Is(err, domain.ErrVerifierNotFound) {
return false, err
}
icon, err := s.UpsertIcon(ctx, domain.VerificationIcon{
DocumentID: domain.VerifierBotDefaultIconDocumentID,
Name: "Default (bundled)",
Active: true,
})
if err != nil {
return false, fmt.Errorf("seed default verifier icon: %w", err)
}
if _, err := s.GrantVerifier(ctx, domain.BotVerifierSettings{
BotID: domain.VerifierBotUserID,
IconDocumentID: icon.DocumentID,
CompanyName: branding.ProductName,
DefaultDescription: "Bundled reference verifier -- auto-granted on first boot.",
CanModifyCustomDescription: false,
Enabled: true,
GrantedBy: "startup-seed",
GrantReason: "Reference verifier auto-granted on first boot so third-party verification has something to demonstrate out of the box.",
}); err != nil {
return false, fmt.Errorf("seed default verifier grant: %w", err)
}
return true, nil
}

View file

@ -48,18 +48,29 @@ const (
// migration 0153; the two must never drift.
VerifyBotAccessHash int64 = 7802113947355620887
// VerifierBotUserID is the built-in @verifierbot: the first THIRD-PARTY
// VerifierBotUserID is the built-in @marksbot: the first THIRD-PARTY
// verifier of a deployment (core.telegram.org/api/bots/verification). It
// collects applications for its own icon+description mark and reports the
// operator's decision back to the applicant. The id is reserved and stable, so
// a restart never re-creates the account under a different identity.
//
// It is not a second route to the platform checkmark: that badge is granted by
// the operator alone and collected by VerifyBotUserID above.
// the operator alone and collected by VerifyBotUserID above. Named "Marks Bot"
// rather than anything containing "Verif*" specifically so it can never be
// misread as a second copy of @verifybot -- the two front doors must stay
// visually distinct at a glance, not just distinct in the underlying mechanism.
VerifierBotUserID int64 = 1250000013
// VerifierBotAccessHash is fixed and double-written with the seed row in
// migration 0156; the two must never drift.
VerifierBotAccessHash int64 = 6913402578811563729
// VerifierBotDefaultIconDocumentID is the custom-emoji document (a ✅ from the
// default "Topics" emoji set, data/sticker-seed/telegram_emoji_export) reused
// as @marksbot's out-of-the-box icon, so the reference verifier has something
// to grant immediately after first boot instead of an empty catalogue. It is
// bundled media that the ordinary sticker-seed import already writes on every
// startup -- not a document minted specifically for this feature -- so it
// resolves the same way any other seeded custom emoji does.
VerifierBotDefaultIconDocumentID int64 = 5237699328843200968
)
// officialSystemUserPhotoDCID/Stripped 由 files.Service.SeedOfficialSystemAvatar
@ -209,19 +220,24 @@ func VerifyBotUser() User {
}
}
// VerifierBotUser returns the built-in @verifierbot account.
// VerifierBotUser returns the built-in @marksbot account.
//
// Verified is false on purpose: the official checkmark is the platform's own
// mechanism, and a third-party verifier wearing it would blur exactly the
// distinction this bot has to explain to every applicant. What makes the account a
// verifier is the operator-granted BotVerifierSettings row, not this seed.
// Verified is true: this deployment carries the platform checkmark on its own
// service bots (see e.g. VerifyBotUser, BotFatherUser), and @marksbot is one of
// them -- a legitimate first-party account, just one that happens to also grant
// a *different*, third-party mark to other peers. The checkmark here says
// "this account is who it claims to be", not "this account's grants are
// official"; that distinction is what @marksbot's own messages explain to every
// applicant, and it does not depend on this bot's own badge being off. What
// makes the account a verifier at all is the operator-granted
// BotVerifierSettings row, not this seed -- the two remain fully independent.
func VerifierBotUser() User {
return User{
ID: VerifierBotUserID,
AccessHash: VerifierBotAccessHash,
FirstName: "Verifier Bot",
Username: "verifierbot",
Verified: false,
FirstName: "Marks Bot",
Username: "marksbot",
Verified: true,
Bot: true,
BotInfoVersion: 1,
}

View file

@ -14,7 +14,7 @@ func TestStarGiftLifecycleMigrationsApply(t *testing.T) {
if err != nil {
t.Fatalf("migrate star gift lifecycle schema: %v", err)
}
if status.Dirty || status.Empty || status.Version != 20260714003125 {
t.Fatalf("migration status = %+v, want clean version 20260714003125", status)
if status.Dirty || status.Empty || status.Version != 20260714003127 {
t.Fatalf("migration status = %+v, want clean version 20260714003127", status)
}
}