Skip to content

Commit

Permalink
feat: handle hook don't have message chat
Browse files Browse the repository at this point in the history
  • Loading branch information
totanvix committed Nov 28, 2023
1 parent 5a6f0f2 commit 8db1ab5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 9 additions & 4 deletions api/hook/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package hook

import (
"encoding/json"
"fmt"
"net/http"
"zeril-bot/utils/bot"
"zeril-bot/utils/structs"
Expand All @@ -16,12 +15,18 @@ func Handler(w http.ResponseWriter, r *http.Request) {
panic(err)
}

fmt.Println("Handler")
fmt.Println(data)
res := make(map[string]string)

if data.Message.Text == "" {
res["status"] = "OK"
res["message"] = "Ignore hook with chat content not found"
Response(w, res, http.StatusOK)
return
}

telegram := telegram.New(&http.Client{}, telegram.BASE_URL)

bot := bot.NewBot(telegram, data)
res := make(map[string]string)

err = bot.ResolveHook()

Expand Down
4 changes: 0 additions & 4 deletions utils/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package bot

import (
"errors"
"fmt"
"log"
"strings"
"time"
Expand Down Expand Up @@ -89,9 +88,6 @@ func (b Bot) resolveCommand() error {

data := b.getTelegramData()

fmt.Println("resolveCommand")
fmt.Println(data)

switch data.Command {
case "/start", "/start@zerill_bot":
err = b.sendStartMessage(data)
Expand Down

0 comments on commit 8db1ab5

Please sign in to comment.