chore: minor cleanup (#2124)

pull/2127/head
YuNing Chen 2 years ago committed by GitHub
parent c835231d32
commit 409d686f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -36,7 +36,7 @@ const (
SystemSettingStorageServiceIDName SystemSettingName = "storage-service-id" SystemSettingStorageServiceIDName SystemSettingName = "storage-service-id"
// SystemSettingLocalStoragePathName is the name of local storage path. // SystemSettingLocalStoragePathName is the name of local storage path.
SystemSettingLocalStoragePathName SystemSettingName = "local-storage-path" SystemSettingLocalStoragePathName SystemSettingName = "local-storage-path"
// SystemSettingTelegramBotToken is the name of Telegram Bot Token. // SystemSettingTelegramBotTokenName is the name of Telegram Bot Token.
SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token" SystemSettingTelegramBotTokenName SystemSettingName = "telegram-bot-token"
// SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts. // SystemSettingMemoDisplayWithUpdatedTsName is the name of memo display with updated ts.
SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts" SystemSettingMemoDisplayWithUpdatedTsName SystemSettingName = "memo-display-with-updated-ts"

@ -20,7 +20,7 @@ const (
UserSettingAppearanceKey UserSettingKey = "appearance" UserSettingAppearanceKey UserSettingKey = "appearance"
// UserSettingMemoVisibilityKey is the key type for user preference memo default visibility. // UserSettingMemoVisibilityKey is the key type for user preference memo default visibility.
UserSettingMemoVisibilityKey UserSettingKey = "memo-visibility" UserSettingMemoVisibilityKey UserSettingKey = "memo-visibility"
// UserSettingTelegramUserID is the key type for telegram UserID of memos user. // UserSettingTelegramUserIDKey is the key type for telegram UserID of memos user.
UserSettingTelegramUserIDKey UserSettingKey = "telegram-user-id" UserSettingTelegramUserIDKey UserSettingKey = "telegram-user-id"
) )

@ -1,6 +1,6 @@
# 1.Prepare your workspace by: # 1.Prepare your workspace by:
# docker compose run api go install github.com/cosmtrek/air@latest # docker compose -f docker-compose.dev.yaml run api go install github.com/cosmtrek/air@latest
# docker compose run web npm install # docker compose -f docker-compose.dev.yaml run web npm install
# #
# 2. Start you work by: # 2. Start you work by:
# docker compose up -d # docker compose up -d

@ -29,7 +29,7 @@ func NewBotWithHandler(h Handler) *Bot {
const noTokenWait = 30 * time.Second const noTokenWait = 30 * time.Second
const errRetryWait = 10 * time.Second const errRetryWait = 10 * time.Second
// Start start an infinity call of getUpdates from Telegram, call r.MessageHandle while get new message updates. // Start start a long polling using getUpdates to get Update, call r.MessageHandle while get new message updates.
func (b *Bot) Start(ctx context.Context) { func (b *Bot) Start(ctx context.Context) {
var offset int var offset int

@ -1,5 +1,7 @@
package telegram package telegram
// CallbackQuery represents an incoming callback query from a callback button in
// an inline keyboard (PUBLIC, PROTECTED, PRIVATE).
type CallbackQuery struct { type CallbackQuery struct {
ID string `json:"id"` ID string `json:"id"`
From User `json:"from"` From User `json:"from"`

@ -14,13 +14,13 @@ type Message struct {
Photo []PhotoSize `json:"photo"` // Photo message is a photo, available sizes of the photo; Photo []PhotoSize `json:"photo"` // Photo message is a photo, available sizes of the photo;
Caption *string `json:"caption"` // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters; Caption *string `json:"caption"` // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters;
Entities []MessageEntity `json:"entities"` // Entities are for text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text; Entities []MessageEntity `json:"entities"` // Entities are for text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text;
CaptionEntities []MessageEntity `json:"caption_entities"` CaptionEntities []MessageEntity `json:"caption_entities"` // CaptionEntities are for messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption;
Document *Document `json:"document"` // Document message is a general file, information about the file; Document *Document `json:"document"` // Document message is a general file, information about the file;
Video *Video `json:"video"` // Video message is a video, information about the video; Video *Video `json:"video"` // Video message is a video, information about the video;
VideoNote *VideoNote `json:"video_note"` // VideoNote message is a video note, information about the video message; VideoNote *VideoNote `json:"video_note"` // VideoNote message is a video note, information about the video message;
Voice *Voice `json:"voice"` // Voice message is a voice message, information about the file; Voice *Voice `json:"voice"` // Voice message is a voice message, information about the file;
Audio *Audio `json:"audio"` // Audio message is an audio file, information about the file; Audio *Audio `json:"audio"` // Audio message is an audio file, information about the file;
Animation *Animation `json:"animation"` // Animation message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set; Animation *Animation `json:"animation"` // Animation message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set;
} }
func (m Message) GetMaxPhotoFileID() string { func (m Message) GetMaxPhotoFileID() string {

@ -48,7 +48,7 @@ func (s *Store) ListUserSettings(ctx context.Context, find *FindUserSetting) ([]
query := ` query := `
SELECT SELECT
user_id, user_id,
key, key,
value value
FROM user_setting FROM user_setting
WHERE ` + strings.Join(where, " AND ") WHERE ` + strings.Join(where, " AND ")

Loading…
Cancel
Save