-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Regenerate lib * Add new handlers for paid media
- Loading branch information
1 parent
1fdf1a9
commit 2a5f7ee
Showing
7 changed files
with
116 additions
and
15 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
ext/handlers/filters/purchasedpaidmedia/purchasedpaidmedia.go
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,24 @@ | ||
package purchasedpaidmedia | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/PaulSonOfLars/gotgbot/v2" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters" | ||
) | ||
|
||
func All(_ *gotgbot.PaidMediaPurchased) bool { | ||
return true | ||
} | ||
|
||
func FromUserID(id int64) filters.PurchasedPaidMedia { | ||
return func(s *gotgbot.PaidMediaPurchased) bool { | ||
return s.From.Id == id | ||
} | ||
} | ||
|
||
func HasPayloadPrefix(pre string) filters.PurchasedPaidMedia { | ||
return func(s *gotgbot.PaidMediaPurchased) bool { | ||
return strings.HasPrefix(s.PaidMediaPayload, pre) | ||
} | ||
} |
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,36 @@ | ||
package handlers | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/PaulSonOfLars/gotgbot/v2" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters" | ||
) | ||
|
||
type PurchasedPaidMedia struct { | ||
Filter filters.PurchasedPaidMedia | ||
Response Response | ||
} | ||
|
||
func NewPurchasedPaidMedia(f filters.PurchasedPaidMedia, r Response) PurchasedPaidMedia { | ||
return PurchasedPaidMedia{ | ||
Filter: f, | ||
Response: r, | ||
} | ||
} | ||
|
||
func (r PurchasedPaidMedia) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool { | ||
if ctx.PreCheckoutQuery == nil { | ||
return false | ||
} | ||
return r.Filter == nil || r.Filter(ctx.PurchasedPaidMedia) | ||
} | ||
|
||
func (r PurchasedPaidMedia) HandleUpdate(b *gotgbot.Bot, ctx *ext.Context) error { | ||
return r.Response(b, ctx) | ||
} | ||
|
||
func (r PurchasedPaidMedia) Name() string { | ||
return fmt.Sprintf("purchasedpaidmedia_%p", r.Response) | ||
} |
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
a3636ebe8a092809f18d3da9ca023259ae3ef8d1 | ||
0fa498977f006abdfa57dd82bb8bc4c33933a7e7 |