update.From when it came from unknown source (CallbackQuery/Message)
@negasus is already working on this.
Since Feb 6, 2025.
Assessment
This issue has not been assessed yet.
Description
Problem
Sometimes, update.Message.From or update.Message.Chat could be nil if it's CallbackQuery update. So, I always need to repeat the same if statement. Example:
var userId int64
var chatId int64
if update.CallbackQuery != nil {
userId = update.CallbackQuery.From.ID
chatId = update.CallbackQuery.Message.Message.Chat.ID
} else {
userId = update.Message.From.ID
chatId = update.Message.Chat.ID
}
Solution
Add the methods FromUser() and FromChat() to models.Update
Conclusion
It will help to easily retrieve the ChatID or UserID from the update. If necessary, I can contribute and send a PR to fix this issue so you can assign me.
- Dominant language
- Go
- Stars
- 1.8k
- Forks
- 161
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from go-telegram/bot
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
go-telegram/bot#293 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
go-telegram/bot#277 ·
-
eqw Open
Difficulty 5/5 Over a week Newbie friendliness 1/100
go-telegram/bot#270 ·
-
Telgram_tipster_bot Open
Difficulty 5/5 Over a week Newbie friendliness 10/100
go-telegram/bot#269 ·
-
Difficulty 5/5 Over a week Newbie friendliness 1/100
go-telegram/bot#268 ·
Similar issues
-
optimization optimization:agents-md-curator
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
githubnext/gh-aw-cao#13143 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
yanet-platform/ipfw-go#129 ·
-
bug confmap/provider/googlesecretmanagerprovider needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
open-telemetry/opentelemetry-collector-contrib#51273 · 2 comments ·
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100