Skip to content

Commit

Permalink
add base_url; update go to 1.22.2; escape series title in /up command (
Browse files Browse the repository at this point in the history
…#2)

* add base_url; update go to 1.22.2; escape series title in /up command

* add base_url; update go to 1.22.2; escape series title in /up command

* add base_url; update go to 1.22.2; escape series title in /up command
  • Loading branch information
woiza authored Apr 27, 2024
1 parent 2f14a85 commit ea49b92
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ services:
- SBOT_SONARR_PROTOCOL=http # http or https
- SBOT_SONARR_PORT=8989
- SBOT_SONARR_HOSTNAME=192.168.2.2 # IP or hostname
- SBOT_SONARR_BASE_URL= # optional, e.g. /sonarr, depending on sonarr configuration
- SBOT_SONARR_API_KEY=1010d7...
```
### Commands for Botfather's /setcommands
Expand Down
2 changes: 1 addition & 1 deletion cmd/bot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func main() {

fmt.Printf("Authorized on account %v\n", b.Self.UserName)

sonarrConfig := starr.New(config.SonarrAPIKey, fmt.Sprintf("%v://%v:%v", config.SonarrProtocol, config.SonarrHostname, config.SonarrPort), 0)
sonarrConfig := starr.New(config.SonarrAPIKey, fmt.Sprintf("%v://%v:%v%v", config.SonarrProtocol, config.SonarrHostname, config.SonarrPort, config.SonarrBaseUrl), 0)
sonarrServer := sonarr.New(sonarrConfig)

botInstance := bot.New(&config, b, sonarrServer)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/woiza/telegram-bot-sonarr

go 1.22.1
go 1.22.2

require (
github.com/go-telegram-bot-api/telegram-bot-api/v5 v5.5.1
Expand Down
3 changes: 2 additions & 1 deletion pkg/bot/library.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
"github.com/woiza/telegram-bot-sonarr/pkg/utils"
"golift.io/starr"
"golift.io/starr/sonarr"
)
Expand Down Expand Up @@ -38,7 +39,7 @@ func (b *Bot) sendUpcoming(episodes []*sonarr.Episode, msg *tgbotapi.MessageConf
seriesMap[episode.SeriesID] = series
}

fmt.Fprintf(&text, "[%v](https://www.imdb.com/title/%v) %vx%02d \\- %v\n", series.Title, series.ImdbID, episode.SeasonNumber, episode.EpisodeNumber, episode.AirDateUtc.Format("02 Jan 2006"))
fmt.Fprintf(&text, "[%v](https://www.imdb.com/title/%v) %vx%02d \\- %v\n", utils.Escape(series.Title), series.ImdbID, episode.SeasonNumber, episode.EpisodeNumber, episode.AirDateUtc.Format("02 Jan 2006"))
}

msg.Text = text.String()
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Config struct {
SonarrHostname string
SonarrPort int
SonarrAPIKey string
SonarrBaseUrl string
}

func LoadConfig() (Config, error) {
Expand All @@ -29,6 +30,7 @@ func LoadConfig() (Config, error) {
config.SonarrHostname = os.Getenv("SBOT_SONARR_HOSTNAME")
sonarrPort := os.Getenv("SBOT_SONARR_PORT")
config.SonarrAPIKey = os.Getenv("SBOT_SONARR_API_KEY")
config.SonarrBaseUrl = os.Getenv("SBOT_SONARR_BASE_URL")

// Validate required fields
if config.TelegramBotToken == "" {
Expand Down

0 comments on commit ea49b92

Please sign in to comment.