Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add telegram api proxy address #93

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
BOT_PROXY_ADDR=https://api.your_proxy_addr.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).
Expand Down
7 changes: 4 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
BotProxyAddr string `env:"BOT_PROXY_ADDR"`
Data string `env:"DATA"`
}

func getConfigFromEnv() (*Config, error) {
Expand Down
3 changes: 3 additions & 0 deletions memogram.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func NewService() (*Service, error) {
bot.WithDefaultHandler(s.handler),
bot.WithCallbackQueryDataHandler("", bot.MatchTypePrefix, s.callbackQueryHandler),
}
if config.BotProxyAddr != "" {
opts = append(opts, bot.WithServerURL(config.BotProxyAddr))
}

b, err := bot.New(config.BotToken, opts...)
if err != nil {
Expand Down