go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API

Home Page:https://go-telegram-bot-api.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panic crash every time I send a file from local path

omerxx opened this issue · comments

Hi!
I'm kind of lost here, tried looking deep into the code here and it doesn't seem to have changed recently.
My app keeps crashing when I try to send a file from local host, this is the code:
(The file does exist within this directory, tried many other files, absolute paths, relative, subdir, everything.

	msg := tgbotapi.NewPhoto(chatId, tgbotapi.FilePath("boto.jpg"))
	if _, err = bot.Send(msg); err != nil {
		log.Error(err)
	}

This is the panic message:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x10 pc=0x101072388]

goroutine 1 [running]:
github.com/go-telegram-bot-api/telegram-bot-api/v5.(*BotAPI).UploadFiles(0x0, {0x1012786e1, 0x9}, 0x1400030e060, {0x140003160a0, 0x1, 0x1})
        /Users/omerhamerman/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api/v5@v5.5.1/bot.go:221 +0x288
github.com/go-telegram-bot-api/telegram-bot-api/v5.(*BotAPI).Request(0x140001f18a8?, {0x10140aa88, 0x14000338090})
        /Users/omerhamerman/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api/v5@v5.5.1/bot.go:326 +0x118
github.com/go-telegram-bot-api/telegram-bot-api/v5.(*BotAPI).Send(_, {_, _})
        /Users/omerhamerman/go/pkg/mod/github.com/go-telegram-bot-api/telegram-bot-api/v5@v5.5.1/bot.go:342 +0x3c
fatbot/reports.CreateChart(0x101691fe0?)
        /Users/omerhamerman/tests/fatbot/reports/reports.go:81 +0x45c
main.main()
        /Users/omerhamerman/tests/fatbot/main.go:14 +0x28
exit status 2

I'd really appreciate any help!

Details

Pardon?

Found my own bug.