mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-04 22:39:26 +00:00
1ff26006f7
Replace the throwaway-local-var-then-take-address pattern with api.Ptr in the polls and moderation examples. Net effect: 14 lines gone, the pointer wrangling no longer steals visual focus from the actual API call.
polls
Create polls and tally answers in real time via OnPollAnswer.
What it shows
api.SendPollwith[]api.InputPollOptionandIsAnonymous: falserouter.OnPollAnswerto receive vote updates (PollAnswer.OptionIds,PollAnswer.User)- Concurrent-safe in-memory tally with
sync.Mutex
Commands
| Command | Description |
|---|---|
/poll <question> |
Creates a poll with four preset options (A/B/C/D) |
/tally <poll_id> |
Shows current vote counts for a poll |
Notes
OnPollAnsweronly fires for non-anonymous polls. For anonymous polls, Telegram does not send user identifiers.- The poll ID is logged when the poll is created; copy it to use with
/tally. - Vote tallies are in-memory and reset on restart.
Running
export TELEGRAM_BOT_TOKEN=123456:ABC...
go run ./examples/polls