Skip to content

Commit

Permalink
feat(handler): added to group
Browse files Browse the repository at this point in the history
Signed-off-by: iyear <ljyngup@gmail.com>
  • Loading branch information
iyear committed Jul 16, 2022
1 parent 3cdc4c4 commit f76f827
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 9 deletions.
9 changes: 0 additions & 9 deletions app/bot/internal/handler/grchan/on_added.go

This file was deleted.

20 changes: 20 additions & 0 deletions app/bot/internal/handler/group/on_added.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package group

import (
"github.com/iyear/searchx/app/bot/internal/util"
tele "gopkg.in/telebot.v3"
)

func OnAdded(c tele.Context) error {
sp := util.GetScope(c)

// 不允许加入普通群组
if c.Chat().Type == tele.ChatGroup {
if err := c.Send(sp.Template.Text.AddedToGroup.Fail.T(nil), &tele.SendOptions{DisableWebPagePreview: true}); err != nil {
return err
}
return c.Bot().Leave(c.Chat())
}

return c.Send(sp.Template.Text.AddedToGroup.Success.T(nil), &tele.SendOptions{DisableWebPagePreview: true})
}
4 changes: 4 additions & 0 deletions app/bot/internal/i18n/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type TemplateText struct {
KeywordsTooLong i18n.Text `mapstructure:"keywords_too_long"`
Results i18n.Text `mapstructure:"results"`
} `mapstructure:"search"`
AddedToGroup struct {
Fail i18n.Text `mapstructure:"fail"`
Success i18n.Text `mapstructure:"success"`
} `mapstructure:"added_to_group"`
Start i18n.Text `mapstructure:"start"`
}

Expand Down
9 changes: 9 additions & 0 deletions config/i18n/zh-cn.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ language = """
👇 请选择需要设置的语言
"""

[text.added_to_group]
fail = """
⚠ 请将群组升级至 `超级群组` | [教程](https://teleme.io/articles/turn_a_telegram_group_into_a_supergroup)
⚠ 请升级后再次邀请 [SearchX Bot](https://github.com/iyear/searchx)
"""

success = "✅ [SearchX Bot](https://github.com/iyear/searchx) 已启用,将索引对话的文本信息。如需索引历史信息,请使用 `source` 命令。"

[button]
back = "⬅ 返回"

Expand Down

0 comments on commit f76f827

Please sign in to comment.