-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update to bot API 7.2 * Add businessconnection filters * Update effectiveX calls to support business messages * Latest regen
- Loading branch information
1 parent
516bfcd
commit ae21465
Showing
11 changed files
with
509 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package handlers | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/PaulSonOfLars/gotgbot/v2" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters" | ||
) | ||
|
||
type BusinessConnection struct { | ||
Filter filters.BusinessConnection | ||
Response Response | ||
} | ||
|
||
func (bc BusinessConnection) CheckUpdate(b *gotgbot.Bot, ctx *ext.Context) bool { | ||
return ctx.BusinessConnection != nil && bc.Filter(ctx.BusinessConnection) | ||
} | ||
|
||
func (bc BusinessConnection) HandleUpdate(b *gotgbot.Bot, ctx *ext.Context) error { | ||
return bc.Response(b, ctx) | ||
} | ||
|
||
func (bc BusinessConnection) Name() string { | ||
return fmt.Sprintf("businessconnection_%p", bc.Response) | ||
} |
32 changes: 32 additions & 0 deletions
32
ext/handlers/filters/businessconnection/businessconnection.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,32 @@ | ||
package message | ||
|
||
import ( | ||
"github.com/PaulSonOfLars/gotgbot/v2" | ||
"github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters" | ||
) | ||
|
||
func All(_ *gotgbot.BusinessConnection) bool { | ||
return true | ||
} | ||
|
||
func BusinessId(businessId string) filters.BusinessConnection { | ||
return func(bc *gotgbot.BusinessConnection) bool { | ||
return bc.Id == businessId | ||
} | ||
} | ||
|
||
func FromUserID(userId int64) filters.BusinessConnection { | ||
return func(bc *gotgbot.BusinessConnection) bool { | ||
return bc.User.Id == userId | ||
} | ||
} | ||
|
||
func ChatID(bc *gotgbot.BusinessConnection, chatId int64) filters.BusinessConnection { | ||
return func(bc *gotgbot.BusinessConnection) bool { | ||
return bc.UserChatId == chatId | ||
} | ||
} | ||
|
||
func CanReply(bc *gotgbot.BusinessConnection) bool { | ||
return bc.CanReply | ||
} |
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
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
Oops, something went wrong.