feat(core): add reply function

This commit is contained in:
tiennm99 committed 2025-12-11 22:31:33 +07:00
1 parent 88e425081b
commit 382e4f7fbf
2 files changed
+18 -1

No files matched your search

+4
View File
@@ -1,3 +1,7 @@
*.sqlite3
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
+14 -1
View File
@@ -7,6 +7,9 @@ import (
"strconv"
"github.com/celestix/gotgproto"
"github.com/celestix/gotgproto/dispatcher/handlers"
"github.com/celestix/gotgproto/dispatcher/handlers/filters"
"github.com/celestix/gotgproto/ext"
"github.com/celestix/gotgproto/sessionMaker"
"github.com/joho/godotenv"
"gorm.io/driver/sqlite"
@@ -45,7 +48,7 @@ func main() {
gotgproto.ClientTypePhone(phoneNumber),
// Optional parameters of client
&gotgproto.ClientOpts{
Session: sessionMaker.SqlSession(sqlite.Open("echobot")),
Session: sessionMaker.SqlSession(sqlite.Open("echobot.sqlite3")),
},
)
if err != nil {
@@ -54,5 +57,15 @@ func main() {
fmt.Printf("client (@%s) has been started...\n", client.Self.Username)
clientDispatcher := client.Dispatcher
clientDispatcher.AddHandlerToGroup(handlers.NewMessage(filters.Message.Text, echo), 1)
client.Idle()
}
func echo(ctx *ext.Context, update *ext.Update) error {
msg := update.EffectiveMessage
_, err := ctx.Reply(update, ext.ReplyTextString(msg.Text), nil)
return err
}