Skip to content

Commit

Permalink
Merge pull request #40 from PinGwynn/Panic-fix/pull
Browse files Browse the repository at this point in the history
Fixed panics on any message in channel and extending debug output
  • Loading branch information
hryamzik committed Jul 25, 2018
2 parents ce11810 + b8475cb commit 3767980
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
"github.com/go-telegram-bot-api/telegram-bot-api"
"gopkg.in/telegram-bot-api.v4"
"gopkg.in/yaml.v2"

"html/template"
Expand Down Expand Up @@ -325,6 +325,13 @@ func telegramBot(bot *tgbotapi.BotAPI) {
}

for update := range updates {
if update.Message == nil {
if *debug {
log.Printf("[UNKNOWN_MESSAGE] [%v]", update)
}
continue
}

if update.Message.NewChatMembers != nil && len(*update.Message.NewChatMembers) > 0 {
for _, member := range *update.Message.NewChatMembers {
if member.UserName == bot.Self.UserName && update.Message.Chat.Type == "group" {
Expand Down Expand Up @@ -395,6 +402,9 @@ func main() {
}

bot = bot_tmp
if *debug {
bot.Debug = true
}
if cfg.TemplatePath != "" {

tmpH = loadTemplate(cfg.TemplatePath)
Expand Down

0 comments on commit 3767980

Please sign in to comment.