Skip to content

Commit

Permalink
fix check for surpers and change anecdot base url
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Mar 2, 2024
1 parent 8361eb1 commit 5da26a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/bot/anecdot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Anecdote struct {

// NewAnecdote makes a bot for http://rzhunemogu.ru
func NewAnecdote(client HTTPClient) *Anecdote {
log.Printf("[INFO] anecdote bot with https://jokesrv.rubedo.cloud/ and https://api.chucknorris.io/jokes/random")
log.Printf("[INFO] anecdote bot with https://jokesrv.fermyon.app and https://api.chucknorris.io/jokes/random")
c, _ := lcw.NewExpirableCache(lcw.MaxKeys(100), lcw.TTL(time.Hour))
return &Anecdote{client: client, categCache: c}
}
Expand Down Expand Up @@ -56,12 +56,12 @@ func (a Anecdote) OnMessage(msg Message) (response Response) {

}

// get categorize from https://jokesrv.rubedo.cloud/categories and extend with / prefix and ! suffix
// get categorize from https://jokesrv.fermyon.app/categories and extend with / prefix and ! suffix
// to mach commands
func (a Anecdote) categories() ([]string, error) {
res, err := a.categCache.Get("categories", func() (interface{}, error) {
var categories []string
req, err := http.NewRequest("GET", "https://jokesrv.rubedo.cloud/categories", http.NoBody)
req, err := http.NewRequest("GET", "https://jokesrv.fermyon.app/categories", http.NoBody)
if err != nil {
return nil, fmt.Errorf("can't make categories request: %w", err)
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (a Anecdote) categories() ([]string, error) {
}

func (a Anecdote) jokesrv(category string) (response Response) {
reqURL := "https://jokesrv.rubedo.cloud/" + category
reqURL := "https://jokesrv.fermyon.app/" + category

req, err := makeHTTPRequest(reqURL)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion app/events/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func (l *TelegramListener) Do(ctx context.Context) error {
log.Printf("[DEBUG] incoming msg: %+v", msg)

// immediately ban channels or groups
if fromChat == l.chatID && msg.SenderChat.ID != 0 && !l.SuperUsers.IsSuper(update.Message.From.UserName) {
allowGroupBan := fromChat == l.chatID && msg.SenderChat.ID != 0 &&
!l.SuperUsers.IsSuper(update.Message.From.UserName) && msg.SenderChat.UserName != "radio_t_podcast"
if allowGroupBan {
log.Printf("[INFO] detected channel/group message, initiating ban: %d %s",
msg.SenderChat.ID, msg.SenderChat.UserName)
permBanDuration := time.Hour * 24 * 400
Expand Down

0 comments on commit 5da26a8

Please sign in to comment.