refactor: change all Robot to Bot (#1767)

* Change all `Robot` to `Bot`

* Change all `r` of `Bot` to `b`

* Change `Robot` to `bot` in comments

* Fix typo

---------

Co-authored-by: Athurg Feng <athurg@gooth.org>
This commit is contained in:
Athurg Gooth
2023-05-29 19:49:05 +08:00
committed by GitHub
parent ddf4cae537
commit 845297ec03
16 changed files with 80 additions and 80 deletions

View File

@@ -26,7 +26,7 @@ type Server struct {
Profile *profile.Profile
Store *store.Store
telegramRobot *telegram.Robot
telegramBot *telegram.Bot
}
func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {
@@ -48,8 +48,8 @@ func NewServer(ctx context.Context, profile *profile.Profile) (*Server, error) {
storeInstance := store.New(db.DBInstance, profile)
s.Store = storeInstance
telegramRobotHandler := newTelegramHandler(storeInstance)
s.telegramRobot = telegram.NewRobotWithHandler(telegramRobotHandler)
telegramBotHandler := newTelegramHandler(storeInstance)
s.telegramBot = telegram.NewBotWithHandler(telegramBotHandler)
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: `{"time":"${time_rfc3339}",` +
@@ -125,7 +125,7 @@ func (s *Server) Start(ctx context.Context) error {
return errors.Wrap(err, "failed to create activity")
}
go s.telegramRobot.Start(ctx)
go s.telegramBot.Start(ctx)
return s.e.Start(fmt.Sprintf(":%d", s.Profile.Port))
}

View File

@@ -65,7 +65,7 @@ func (s *Server) registerSystemRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find system setting list").SetInternal(err)
}
for _, systemSetting := range systemSettingList {
if systemSetting.Name == api.SystemSettingServerIDName || systemSetting.Name == api.SystemSettingSecretSessionName || systemSetting.Name == api.SystemSettingOpenAIConfigName || systemSetting.Name == api.SystemSettingTelegramRobotTokenName {
if systemSetting.Name == api.SystemSettingServerIDName || systemSetting.Name == api.SystemSettingSecretSessionName || systemSetting.Name == api.SystemSettingOpenAIConfigName || systemSetting.Name == api.SystemSettingTelegramBotTokenName {
continue
}

View File

@@ -21,8 +21,8 @@ func newTelegramHandler(store *store.Store) *telegramHandler {
return &telegramHandler{store: store}
}
func (t *telegramHandler) RobotToken(ctx context.Context) string {
return t.store.GetSystemSettingValueOrDefault(&ctx, api.SystemSettingTelegramRobotTokenName, "")
func (t *telegramHandler) BotToken(ctx context.Context) string {
return t.store.GetSystemSettingValueOrDefault(&ctx, api.SystemSettingTelegramBotTokenName, "")
}
func (t *telegramHandler) MessageHandle(ctx context.Context, message telegram.Message, blobs map[string][]byte) error {