Skip to content

Commit 4c0c5eb

Browse files
committed
chore: Update version to 0.6.11 and add GroupID field to telegramConfig
1 parent 59e6b1e commit 4c0c5eb

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

cmd/version.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
const (
10-
Version string = "0.6.10"
10+
Version string = "0.6.11"
1111
)
1212

1313
var VersionCmd = &cobra.Command{

config/telegram.go

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ type telegramConfig struct {
77
Username string `toml:"username" mapstructure:"username" json:"username" yaml:"username"`
88
Sleep uint `toml:"sleep" mapstructure:"sleep" json:"sleep" yaml:"sleep"`
99
Admins []int64 `toml:"admins" mapstructure:"admins" json:"admins" yaml:"admins"`
10+
GroupID int64 `toml:"group_id" mapstructure:"group_id" json:"group_id" yaml:"group_id"`
1011
}

telegram/telegram.go

+26-7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var (
1414
Bot *telego.Bot
1515
BotUsername string // 没有 @
1616
ChannelChatID telego.ChatID
17+
GroupChatID telego.ChatID // 附属群组
1718
)
1819

1920
func InitBot() {
@@ -33,6 +34,10 @@ func InitBot() {
3334
ChannelChatID = telegoutil.ID(config.Cfg.Telegram.ChatID)
3435
}
3536

37+
if config.Cfg.Telegram.GroupID != 0 {
38+
GroupChatID = telegoutil.ID(config.Cfg.Telegram.GroupID)
39+
}
40+
3641
me, err := Bot.GetMe()
3742
if err != nil {
3843
Logger.Errorf("Error when getting bot info: %s", err)
@@ -111,11 +116,25 @@ func InitBot() {
111116
},
112117
}
113118

114-
Bot.SetMyCommands(&telego.SetMyCommandsParams{
115-
Commands: append(commonCommands, adminCommands...),
116-
Scope: &telego.BotCommandScopeChat{
117-
Type: telego.ScopeTypeChat,
118-
ChatID: telegoutil.ID(config.Cfg.Telegram.Admins[0]),
119-
},
120-
})
119+
adminCommands = append(adminCommands, commonCommands...)
120+
121+
for _, adminID := range config.Cfg.Telegram.Admins {
122+
Bot.SetMyCommands(&telego.SetMyCommandsParams{
123+
Commands: adminCommands,
124+
Scope: &telego.BotCommandScopeChat{
125+
Type: telego.ScopeTypeChat,
126+
ChatID: telegoutil.ID(adminID),
127+
},
128+
})
129+
if config.Cfg.Telegram.GroupID == 0 {
130+
continue
131+
}
132+
Bot.SetMyCommands(&telego.SetMyCommandsParams{
133+
Commands: adminCommands,
134+
Scope: &telego.BotCommandScopeChat{
135+
Type: telego.ScopeTypeChat,
136+
ChatID: telegoutil.ID(adminID),
137+
},
138+
})
139+
}
121140
}

0 commit comments

Comments
 (0)