Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: update telegram integration folder
Steven7da10cd367f5
diff --git a/server/telegram.go b/server/integration/telegram.gosimilarity index 94%rename from server/telegram.gorename to server/integration/telegram.goindex aadd8ab73..4ffa90f68 100644--- a/server/telegram.go+++ b/server/integration/telegram.go@@ -1,4 +1,4 @@-package server+package integrationimport ("bytes"@@ -15,15 +15,15 @@ import ("github.com/usememos/memos/store")-type telegramHandler struct {+type TelegramHandler struct {store *store.Store}-func newTelegramHandler(store *store.Store) *telegramHandler {- return &telegramHandler{store: store}+func NewTelegramHandler(store *store.Store) *TelegramHandler {+ return &TelegramHandler{store: store}}-func (t *telegramHandler) BotToken(ctx context.Context) string {+func (t *TelegramHandler) BotToken(ctx context.Context) string {return t.store.GetSystemSettingValueWithDefault(&ctx, apiv1.SystemSettingTelegramBotTokenName.String(), "")}@@ -32,7 +32,7 @@ const (successMessage = "Success")-func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot, message telegram.Message, attachments []telegram.Attachment) error {+func (t *TelegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot, message telegram.Message, attachments []telegram.Attachment) error {reply, err := bot.SendReplyMessage(ctx, message.Chat.ID, message.MessageID, workingMessage)if err != nil {return errors.Wrap(err, "Failed to SendReplyMessage")@@ -121,7 +121,7 @@ func (t *telegramHandler) MessageHandle(ctx context.Context, bot *telegram.Bot,return err}-func (t *telegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram.Bot, callbackQuery telegram.CallbackQuery) error {+func (t *TelegramHandler) CallbackQueryHandle(ctx context.Context, bot *telegram.Bot, callbackQuery telegram.CallbackQuery) error {var memoID int32var visibility store.Visibilityn, err := fmt.Sscanf(callbackQuery.Data, "%s %d", &visibility, &memoID)diff --git a/server/server.go b/server/server.goindex ddd66c4e9..f074a8efc 100644--- a/server/server.go+++ b/server/server.go@@ -20,6 +20,7 @@ import (apiv2 "github.com/usememos/memos/api/v2""github.com/usememos/memos/common/log""github.com/usememos/memos/plugin/telegram"+ "github.com/usememos/memos/server/integration""github.com/usememos/memos/server/profile""github.com/usememos/memos/server/service""github.com/usememos/memos/store"@@ -47,7 +48,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Storee.HideBanner = truee.HidePort = true- telegramBot := telegram.NewBotWithHandler(newTelegramHandler(store))s := &Server{e: e,Store: store,@@ -55,7 +55,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store// Asynchronous runners.backupRunner: service.NewBackupRunner(store),- telegramBot: telegramBot,+ telegramBot: telegram.NewBotWithHandler(integration.NewTelegramHandler(store)),}e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{@@ -118,7 +118,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Stores.Secret = secretrootGroup := e.Group("")- apiV1Service := apiv1.NewAPIV1Service(s.Secret, profile, store, telegramBot)+ apiV1Service := apiv1.NewAPIV1Service(s.Secret, profile, store, s.telegramBot)apiV1Service.Register(rootGroup)s.apiV2Service = apiv2.NewAPIV2Service(s.Secret, profile, store, s.Profile.Port+1)