fix: url in bot message (#50)

* fix: url in bot message

* Update .env.example

Co-authored-by: boojack <24653555+boojack@users.noreply.github.com>

* feat: rename MEMOS_ADDR to INSTANCE_URL

* feat: rename MEMOS_ADDR to INSTANCE_URL

* feat: rename MEMOS_ADDR to INSTANCE_URL

* fix: formatting

---------

Co-authored-by: boojack <24653555+boojack@users.noreply.github.com>
This commit is contained in:
wolfsilver
2024-08-27 08:05:26 +08:00
committed by GitHub
parent 5d7dc80cbc
commit ba7534e590
4 changed files with 9 additions and 5 deletions

View File

@@ -1,2 +1,3 @@
SERVER_ADDR=dns:localhost:5230
BOT_TOKEN=your_bot_token
BOT_TOKEN=your_bot_token
INSTANCE_URL=https://memos.example.com

View File

@@ -18,6 +18,7 @@ Create a `.env` file in the project's root directory and add the following confi
```env
SERVER_ADDR=dns:localhost:5230
BOT_TOKEN=your_telegram_bot_token
INSTANCE_URL=https://memos.example.com
```
The `SERVER_ADDR` should be a gRPC server address that the Memos is running on. It follows the [gRPC Name Resolution](https://github.com/grpc/grpc/blob/master/doc/naming.md).
@@ -64,6 +65,7 @@ Or you can start the service with Docker Compose. This can be combined with the
```sh
SERVER_ADDR=dns:yourMemosUrl.com:5230
BOT_TOKEN=your_telegram_bot_token
INSTANCE_URL=https://memos.example.com
```
4. Create Docker Compose `docker-compose.yml` file:
```yaml

View File

@@ -10,9 +10,10 @@ import (
)
type Config struct {
ServerAddr string `env:"SERVER_ADDR,required"`
BotToken string `env:"BOT_TOKEN,required"`
Data string `env:"DATA"`
ServerAddr string `env:"SERVER_ADDR,required"`
BotToken string `env:"BOT_TOKEN,required"`
InstanceUrl string `env:"INSTANCE_URL"`
Data string `env:"DATA"`
}
func getConfigFromEnv() (*Config, error) {

View File

@@ -177,7 +177,7 @@ func (s *Service) handler(ctx context.Context, b *bot.Bot, m *models.Update) {
b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: m.Message.Chat.ID,
Text: fmt.Sprintf("Content saved as %s with [%s](%s/m/%s)", v1pb.Visibility_name[int32(memo.Visibility)], memo.Name, s.config.ServerAddr, memo.Uid),
Text: fmt.Sprintf("Content saved as %s with [%s](%s/m/%s)", v1pb.Visibility_name[int32(memo.Visibility)], memo.Name, s.config.InstanceUrl, memo.Uid),
ParseMode: models.ParseModeMarkdown,
DisableNotification: true,
ReplyParameters: &models.ReplyParameters{