-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: tgWebhookUsersSharedMessage + photo_size.go
- Loading branch information
1 parent
c3fdaa0
commit 4bfa803
Showing
6 changed files
with
108 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package telegram | ||
|
||
import ( | ||
"github.com/bots-go-framework/bots-api-telegram/tgbotapi" | ||
"github.com/bots-go-framework/bots-fw/botinput" | ||
) | ||
|
||
var _ botinput.PhotoMessageItem = (*photoSize)(nil) | ||
|
||
type photoSize struct { | ||
tgbotapi.PhotoSize | ||
} | ||
|
||
func (v photoSize) GetFileID() string { | ||
return v.FileID | ||
} | ||
|
||
func (v photoSize) GetWidth() int { | ||
return v.Width | ||
} | ||
|
||
func (v photoSize) GetHeight() int { | ||
return v.Height | ||
} | ||
|
||
func (v photoSize) GetFileSize() int { | ||
return v.FileSize | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package telegram | ||
|
||
import ( | ||
"github.com/bots-go-framework/bots-api-telegram/tgbotapi" | ||
"github.com/bots-go-framework/bots-fw/botinput" | ||
"strconv" | ||
) | ||
|
||
var _ botinput.WebhookSharedUserMessage = (*tgWebhookUsersSharedMessage)(nil) | ||
|
||
type tgWebhookUsersSharedMessage struct { | ||
tgWebhookMessage | ||
TgMessageType TgMessageType | ||
} | ||
|
||
func (m tgWebhookUsersSharedMessage) GetSharedUsers() []botinput.SharedUserMessageItem { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (tgWebhookUsersSharedMessage) InputType() botinput.WebhookInputType { | ||
return botinput.WebhookInputSharedUsers | ||
} | ||
|
||
func newTgWebhookUsersSharedMessage(input tgWebhookInput, tgMessageType TgMessageType, tgMessage *tgbotapi.Message) tgWebhookUsersSharedMessage { | ||
return tgWebhookUsersSharedMessage{ | ||
tgWebhookMessage: newTelegramWebhookMessage(input, tgMessage), | ||
TgMessageType: tgMessageType, | ||
} | ||
} | ||
|
||
var _ botinput.SharedUserMessageItem = (*tgSharedUser)(nil) | ||
|
||
type tgSharedUser struct { | ||
tgbotapi.SharedUser | ||
} | ||
|
||
func (v tgSharedUser) GetBotUserID() string { | ||
return strconv.Itoa(v.UserID) | ||
} | ||
|
||
func (v tgSharedUser) GetUsername() string { | ||
return v.Username | ||
} | ||
|
||
func (v tgSharedUser) GetFirstName() string { | ||
return v.Username | ||
} | ||
|
||
func (v tgSharedUser) GetLastName() string { | ||
return v.LastName | ||
} | ||
|
||
func (v tgSharedUser) GetPhotos() (photos []botinput.PhotoMessageItem) { | ||
photos = make([]botinput.PhotoMessageItem, len(v.Photo)) | ||
for i, photo := range v.Photo { | ||
photos[i] = photoSize{PhotoSize: photo} | ||
} | ||
return | ||
} |