You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something like ChatID helper type which is actually int64 that implements Recipient interface and returns itself. It would make work with specific chat IDs much easier.
demget
changed the title
Proposal: Special ChatID to describe Recipient by its ID
Proposal: Special ChatID type to describe Recipient by its ID
Apr 16, 2020
demget
changed the title
Proposal: Special ChatID type to describe Recipient by its ID
Proposal: Special ChatID type to describe Recipient only by its integer ID
Apr 16, 2020
The possible problem is that you can't represent a string username as a recipient. But on the other hand, ChatID type is about ID, not Name.
// ChatID represents a chat or an user integer ID, which can be used// as recipient in bot methods. It is very useful in cases where// you have special group IDs, for example in your config, and don't// want to wrap it into *tb.Chat every time you send messages.//// Example://// group := tb.ChatID(-100756389456)// b.Send(group, "Hello!")//// type Config struct {// AdminGroup tb.ChatID `json:"admin_group"`// }// b.Send(conf.AdminGroup, "Hello!")//typeChatIDint64// Recipient returns chat ID (see Recipient interface).func (iChatID) Recipient() string {
returnstrconv.FormatInt(int64(i), 10)
}
Something like
ChatID
helper type which is actuallyint64
that implementsRecipient
interface and returns itself. It would make work with specific chat IDs much easier.Before:
After:
The text was updated successfully, but these errors were encountered: