68 lines
1.8 KiB
Go
68 lines
1.8 KiB
Go
package domain
|
|
|
|
const (
|
|
// OfficialSystemUserID 是 Telegram 兼容客户端识别的官方系统账号。
|
|
OfficialSystemUserID int64 = 777000
|
|
|
|
// BotFatherUserID 是内置 BotFather 账号,与官方 @BotFather 同 ID。
|
|
BotFatherUserID int64 = 93372553
|
|
// BotFatherAccessHash 固定不变;与迁移 0090 的种子行双写,必须保持一致。
|
|
BotFatherAccessHash int64 = 7421896403922962293
|
|
)
|
|
|
|
// OfficialSystemUser 返回第一阶段内置的官方系统账号。
|
|
func OfficialSystemUser() User {
|
|
return User{
|
|
ID: OfficialSystemUserID,
|
|
AccessHash: 6599886787491911851,
|
|
Phone: "42777",
|
|
FirstName: "Telegram",
|
|
Username: "telegram",
|
|
Verified: true,
|
|
Support: true,
|
|
}
|
|
}
|
|
|
|
// BotFatherUser 返回内置 BotFather 账号。username 不以 bot 结尾属种子例外(与官方一致)。
|
|
func BotFatherUser() User {
|
|
return User{
|
|
ID: BotFatherUserID,
|
|
AccessHash: BotFatherAccessHash,
|
|
FirstName: "BotFather",
|
|
Username: "BotFather",
|
|
Verified: true,
|
|
Bot: true,
|
|
BotInfoVersion: 1,
|
|
}
|
|
}
|
|
|
|
// SystemUserByID 返回内置系统账号;非系统账号返回 ok=false。
|
|
// 所有对 777000 的硬编码注入点统一经此函数,新增内置账号只改这里。
|
|
func SystemUserByID(id int64) (User, bool) {
|
|
switch id {
|
|
case OfficialSystemUserID:
|
|
return OfficialSystemUser(), true
|
|
case BotFatherUserID:
|
|
return BotFatherUser(), true
|
|
}
|
|
return User{}, false
|
|
}
|
|
|
|
func IsSystemUserID(id int64) bool {
|
|
_, ok := SystemUserByID(id)
|
|
return ok
|
|
}
|
|
|
|
func SystemUserByPhone(phone string) (User, bool) {
|
|
phone = NormalizePhone(phone)
|
|
for _, id := range []int64{OfficialSystemUserID, BotFatherUserID} {
|
|
u, ok := SystemUserByID(id)
|
|
if !ok || u.Phone == "" {
|
|
continue
|
|
}
|
|
if NormalizePhone(u.Phone) == phone {
|
|
return u, true
|
|
}
|
|
}
|
|
return User{}, false
|
|
}
|