Skip to content

Commit

Permalink
feat: tgWebhookUsersSharedMessage + photo_size.go
Browse files Browse the repository at this point in the history
  • Loading branch information
trakhimenok committed Jan 24, 2025
1 parent c3fdaa0 commit 4bfa803
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 5 deletions.
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ go 1.22.3
//replace github.com/bots-go-framework/bots-fw-store => ../bots-fw-store

require (
github.com/bots-go-framework/bots-api-telegram v0.7.3
github.com/bots-go-framework/bots-fw v0.40.6
github.com/bots-go-framework/bots-fw-store v0.8.2
github.com/bots-go-framework/bots-api-telegram v0.8.1
github.com/bots-go-framework/bots-fw v0.41.0
github.com/bots-go-framework/bots-fw-store v0.10.0
github.com/bots-go-framework/bots-fw-telegram-models v0.3.9
github.com/dal-go/dalgo v0.14.2
github.com/pquerna/ffjson v0.0.0-20190930134022-aa0246cd15f7
Expand All @@ -22,6 +22,7 @@ require (
github.com/bots-go-framework/bots-go-core v0.0.3 // indirect
github.com/strongo/gamp v0.0.1 // indirect
github.com/strongo/random v0.0.1 // indirect
github.com/strongo/slice v0.3.1 // indirect
github.com/strongo/strongoapp v0.25.5 // indirect
github.com/strongo/validation v0.0.7 // indirect
github.com/technoweenie/multipartstreamer v1.0.1 // indirect
Expand Down
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ github.com/bots-go-framework/bots-api-telegram v0.7.2 h1:opeFCvSlmMdm84WbJhXjqg7
github.com/bots-go-framework/bots-api-telegram v0.7.2/go.mod h1:BGnZGzmMX9x9/18W6BT2j8BU3LZXypj2rYuZfqgq87o=
github.com/bots-go-framework/bots-api-telegram v0.7.3 h1:zGbyTxggz6NPyhCjmJPLZyd3GL1fltjA7xhSnVvbNqA=
github.com/bots-go-framework/bots-api-telegram v0.7.3/go.mod h1:aY3y10SeCY4K3pHOrqOxXImjs8CfYD7n71Q5VZXKkJw=
github.com/bots-go-framework/bots-api-telegram v0.8.0 h1:E2RUHEoyL84b2zdH/Ckgg2PwRVyCMil9SaQUuUf9kCo=
github.com/bots-go-framework/bots-api-telegram v0.8.0/go.mod h1:aY3y10SeCY4K3pHOrqOxXImjs8CfYD7n71Q5VZXKkJw=
github.com/bots-go-framework/bots-api-telegram v0.8.1 h1:dgF2Or8B8ELjCLwKhxxyk33NlEYZaM38XvFaWp/CyiE=
github.com/bots-go-framework/bots-api-telegram v0.8.1/go.mod h1:aY3y10SeCY4K3pHOrqOxXImjs8CfYD7n71Q5VZXKkJw=
github.com/bots-go-framework/bots-fw v0.38.2 h1:8w06QdDbQnc80dRRxipZCoAeXS92r1ife6XUXego36s=
github.com/bots-go-framework/bots-fw v0.38.2/go.mod h1:rvwJ5HFLiRpaNypXPO8fEDcf5/oJOmOEs5/fH+1vVV0=
github.com/bots-go-framework/bots-fw v0.40.1 h1:9WM2T498HT0rEf+6TIMexPx2y00Leycujrf6BMidXSY=
Expand All @@ -16,8 +20,14 @@ github.com/bots-go-framework/bots-fw v0.40.4 h1:+PtLDbWUvr2J9xUnKtUTxAQl0Ka25ZjB
github.com/bots-go-framework/bots-fw v0.40.4/go.mod h1:KeNhMTMTiCymF8OeCADxTljQa8igCmSSqL2gqnr6W+A=
github.com/bots-go-framework/bots-fw v0.40.6 h1:GpsqOuELd9VuV7qBuKTv9ospkIrwh8TF3Aj2724BiF8=
github.com/bots-go-framework/bots-fw v0.40.6/go.mod h1:baBLMsoY14odhgYBCtsWr3e3scD9FgoWyK0E5FQY4i4=
github.com/bots-go-framework/bots-fw v0.40.8 h1:4gaJw7g8LFFDq1Nx2zc8sQxOztYUr5HqUYh/vIuFFM8=
github.com/bots-go-framework/bots-fw v0.40.8/go.mod h1:sx4RV2tuW3P/Qu2JM+38+aRE+NsMkwzGG4efn7eyMzs=
github.com/bots-go-framework/bots-fw v0.41.0 h1:hghaPDxeLZ6aKaudOtXSJGcVLNp2pd5hqbOQBY45A3M=
github.com/bots-go-framework/bots-fw v0.41.0/go.mod h1:sx4RV2tuW3P/Qu2JM+38+aRE+NsMkwzGG4efn7eyMzs=
github.com/bots-go-framework/bots-fw-store v0.8.2 h1:Ss2ZRFoBeNgEy1TWzRIoVdERMoAv1kp9GlJvq3EbiHo=
github.com/bots-go-framework/bots-fw-store v0.8.2/go.mod h1:ZxeNr86seS59kKyf9zol15vdZEcH+1CjjzHOFokGrVI=
github.com/bots-go-framework/bots-fw-store v0.10.0 h1:e6bD274mjrHVp+X05/7uqqT3s5xZOqV9divKTaM2W+w=
github.com/bots-go-framework/bots-fw-store v0.10.0/go.mod h1:7oU4B8j5HuJZM8AftosbyQD+AqckXsDv8eU1auGPzn8=
github.com/bots-go-framework/bots-fw-telegram-models v0.3.4 h1:THQk9o0XzgEgRfBOxUVxXaj2hfUgkeWBW42CWugUnlI=
github.com/bots-go-framework/bots-fw-telegram-models v0.3.4/go.mod h1:V5qMb0S/p2bE3ENF1NmO0c9M4iPUnEPwmn++d1yM32Q=
github.com/bots-go-framework/bots-fw-telegram-models v0.3.5 h1:zI/tAHp0sN95JoSJu0N6PEs9eHhKiva+6EHsgCzLWqo=
Expand Down Expand Up @@ -65,6 +75,8 @@ github.com/strongo/logus v0.2.1 h1:ZzAtdSg6PPF1Y43WbNWl7MH1XYl7kvKMxyxv/lpbadI=
github.com/strongo/logus v0.2.1/go.mod h1:sd8gjJklqGQAg+Q0mlP5MWgzguAuxR25YYFSkfVOPdc=
github.com/strongo/random v0.0.1 h1:OZHJBb/3uEa7OX8L2Dv2pLnSeewRmXMyTACoeto6O8I=
github.com/strongo/random v0.0.1/go.mod h1:/pSI+SjBNLBkjljNtVdYr6ERddA+LqSa87o0/s+9iuU=
github.com/strongo/slice v0.3.1 h1:VWkyYBgcVJn6Hs7wYhL9Vxwgb7V3zQAUFTBV9wo5lc4=
github.com/strongo/slice v0.3.1/go.mod h1:B5ODKCkl0rp2oiG0UBqkN1cCOrSCU2cUuhqCM1sC8r4=
github.com/strongo/strongoapp v0.24.3 h1:+5pXWoaeD81BnjIHOYqpdGbK6syeEDV7RTCnBi+ywLI=
github.com/strongo/strongoapp v0.24.3/go.mod h1:lmqjpbP+aTKJLN0R+M+jwpe6Kf8+t1X30cyc6GlGoW4=
github.com/strongo/strongoapp v0.25.0 h1:KJyDaD14PIs55S4hw15QrIMbHBPkAor9ezgpOxKRaiE=
Expand Down
28 changes: 28 additions & 0 deletions telegram/photo_size.go
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
}
2 changes: 2 additions & 0 deletions telegram/webhook_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func message2input(input tgWebhookInput, tgMessageType TgMessageType, tgMessage
return newTgWebhookAudioMessage(input, tgMessageType, tgMessage)
case tgMessage.Sticker != nil:
return newTgWebhookStickerMessage(input, tgMessageType, tgMessage)
case tgMessage.UsersShared != nil:
return newTgWebhookUsersSharedMessage(input, tgMessageType, tgMessage)
default:
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions telegram/webhook_msg_photo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"github.com/bots-go-framework/bots-fw/botinput"
)

var _ botinput.WebhookPhotoMessage = (*tgWebhookPhotoMessage)(nil)

type tgWebhookPhotoMessage struct {
tgWebhookMessage
TgMessageType TgMessageType
}

var _ botinput.WebhookPhotoMessage = (*tgWebhookPhotoMessage)(nil)

func (tgWebhookPhotoMessage) InputType() botinput.WebhookInputType {
return botinput.WebhookInputPhoto
}
Expand Down
60 changes: 60 additions & 0 deletions telegram/webhook_msg_users_shared.go
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
}

0 comments on commit 4bfa803

Please sign in to comment.