34 lines
842 B
Go
34 lines
842 B
Go
package telegram
|
|
|
|
import "github.com/mymmrac/telego"
|
|
|
|
func updateFrom(update telego.Update) *telego.User {
|
|
if update.Message != nil {
|
|
return update.Message.From
|
|
}
|
|
if update.CallbackQuery != nil {
|
|
return &update.CallbackQuery.From
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func updateChatID(update telego.Update) (int64, bool) {
|
|
if update.Message != nil {
|
|
return update.Message.Chat.ID, true
|
|
}
|
|
if update.CallbackQuery != nil && update.CallbackQuery.Message != nil {
|
|
return update.CallbackQuery.Message.GetChat().ID, true
|
|
}
|
|
return 0, false
|
|
}
|
|
|
|
func isPrivateChat(update telego.Update) bool {
|
|
if update.Message != nil {
|
|
return update.Message.Chat.Type == telego.ChatTypePrivate
|
|
}
|
|
if update.CallbackQuery != nil && update.CallbackQuery.Message != nil {
|
|
return update.CallbackQuery.Message.GetChat().Type == telego.ChatTypePrivate
|
|
}
|
|
return true
|
|
}
|