From 3a0c4b2a1652cdce6da3592c19a53d95e76a8e7f Mon Sep 17 00:00:00 2001 From: celestix <73958752+celestix@users.noreply.github.com> Date: Mon, 13 May 2024 17:23:42 +0530 Subject: [PATCH] bump up gotgproto --- README.md | 2 +- adding_modules.md | 12 +++--- bot/help.go | 4 +- config/config.go | 17 +++++--- go.mod | 58 ++++++++++++++++----------- go.sum | 71 ++++++++++++++++++++++++++++++++- main.go | 99 +++++++++++++++++++++------------------------- modules/admin.go | 29 +++++++------- modules/afk.go | 26 ++++++------ modules/help.go | 12 +++--- modules/misc.go | 25 ++++++------ modules/modules.go | 8 ++-- modules/prog.go | 8 ++-- modules/shell.go | 10 ++--- modules/update.go | 10 ++--- utils/extract.go | 12 +++--- utils/startup.go | 52 +++++++++++++----------- 17 files changed, 267 insertions(+), 188 deletions(-) diff --git a/README.md b/README.md index 21c59fd..17fc2ce 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

-GIGA is a powerful telegram userbot written in Go with the help of [gotd](https://github.com/gotd/td) and [gotgproto](https://github.com/anonyindian/gotgproto). +GIGA is a powerful telegram userbot written in Go with the help of [gotd](https://github.com/gotd/td) and [gotgproto](https://github.com/celestix/gotgproto). ## Deployment The userbot is still under development but you can deploy it through your console by following a few steps: diff --git a/adding_modules.md b/adding_modules.md index 7bfc4aa..bb1bb0b 100644 --- a/adding_modules.md +++ b/adding_modules.md @@ -22,7 +22,7 @@ All the handlers will be allocated to the main dispatcher stream through this `L package modules import ( - "github.com/anonyindian/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher" ) func (*module) LoadFoo(dp *dispatcher.CustomDispatcher) { @@ -73,7 +73,7 @@ In order to add help section for your module, you have to call `SetModuleHelp` f package modules import ( - "github.com/anonyindian/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher" ) func (*module) LoadFoo(dp *dispatcher.CustomDispatcher) { @@ -99,10 +99,10 @@ package modules import ( "fmt" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/dispatcher/handlers/filters" - "github.com/anonyindian/gotgproto/ext" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/dispatcher/handlers/filters" + "github.com/celestix/gotgproto/ext" "github.com/anonyindian/logger" "github.com/gigauserbot/giga/bot/helpmaker" ) diff --git a/bot/help.go b/bot/help.go index b644160..a537efa 100644 --- a/bot/help.go +++ b/bot/help.go @@ -10,9 +10,9 @@ import ( "github.com/PaulSonOfLars/gotgbot/v2/ext/handlers" "github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters/callbackquery" "github.com/PaulSonOfLars/gotgbot/v2/ext/handlers/filters/inlinequery" - "github.com/anonyindian/gotgproto" "github.com/anonyindian/logger" "github.com/gigauserbot/giga/bot/helpmaker" + "github.com/gigauserbot/giga/config" ) func helpInline(b *gotgbot.Bot, ctx *ext.Context) error { @@ -41,7 +41,7 @@ func helpInline(b *gotgbot.Bot, ctx *ext.Context) error { func helpCallback(b *gotgbot.Bot, ctx *ext.Context) error { query := ctx.CallbackQuery - if query.From.Id != gotgproto.Self.ID { + if query.From.Id != config.Self.ID { query.Answer(b, &gotgbot.AnswerCallbackQueryOpts{ Url: fmt.Sprintf("t.me/%s?start=deploy_own_via_help", strings.TrimPrefix(b.Username, "@")), }) diff --git a/config/config.go b/config/config.go index 646d39c..e6e0020 100644 --- a/config/config.go +++ b/config/config.go @@ -6,8 +6,9 @@ import ( "os" "strings" - "github.com/anonyindian/gotgproto/sessionMaker" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/sessionMaker" + "github.com/gotd/td/tg" ) const DEBUG = false @@ -28,6 +29,8 @@ type config struct { BotToken string `json:"bot_token,omitempty"` } +var Self *tg.User + func Load(l *logger.Logger) { l = l.Create("CONFIG") defer l.ChangeLevel(logger.LevelMain).Println("LOADED") @@ -47,20 +50,22 @@ func Load(l *logger.Logger) { } } -func GetSessionString() string { +func getSessionString() string { if ValueOf.TestServer { return ValueOf.TestSessionString } return ValueOf.SessionString } -func GetSessionType() sessionMaker.SessionType { +func GetSession() sessionMaker.SessionConstructor { + sessionString := getSessionString() + const sessionName = "giga" switch strings.ToLower(ValueOf.SessionType) { case "pyrogram", "pyro": - return sessionMaker.PyrogramSession + return sessionMaker.PyrogramSession(sessionString).Name(sessionName) case "gotgproto", "native": - return sessionMaker.StringSession + return sessionMaker.StringSession(sessionString).Name(sessionName) default: - return sessionMaker.TelethonSession + return sessionMaker.TelethonSession(sessionString).Name(sessionName) } } diff --git a/go.mod b/go.mod index 7abc3d7..79e414f 100644 --- a/go.mod +++ b/go.mod @@ -1,32 +1,39 @@ module github.com/gigauserbot/giga // +heroku goVersion go1.18 -go 1.18 +go 1.21 + +toolchain go1.22.2 require ( github.com/PaulSonOfLars/gotgbot/v2 v2.0.0-rc.11 - github.com/anonyindian/gotgproto v1.0.0-beta08.0.20220813082126-f98d0f42e1d5 - github.com/anonyindian/logger v1.0.0-alpha.3 + github.com/anonyindian/logger v1.0.0-alpha.3.0.20220812175701-2dba945b21ba + github.com/celestix/gotgproto v1.0.0-beta17.0.20240511154527-4b606be36214 github.com/go-git/go-git/v5 v5.4.2 github.com/go-redis/redis v6.15.9+incompatible - github.com/gotd/td v0.68.1 + github.com/gotd/td v0.102.0 github.com/joho/godotenv v1.4.0 ) require ( + github.com/AnimeKaizoku/cacher v1.0.1 // indirect github.com/Microsoft/go-winio v0.5.2 // indirect github.com/ProtonMail/go-crypto v0.0.0-20220824120805-4b6e5c587895 // indirect github.com/acomagu/bufpipe v1.0.3 // indirect github.com/allegro/bigcache v1.2.1 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect + github.com/cenkalti/backoff/v4 v4.3.0 // indirect github.com/cloudflare/circl v1.2.0 // indirect + github.com/dustin/go-humanize v1.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/go-faster/errors v0.6.1 // indirect - github.com/go-faster/jx v0.39.0 // indirect - github.com/go-faster/xor v0.3.0 // indirect + github.com/glebarez/go-sqlite v1.22.0 // indirect + github.com/glebarez/sqlite v1.11.0 // indirect + github.com/go-faster/errors v0.7.1 // indirect + github.com/go-faster/jx v1.1.0 // indirect + github.com/go-faster/xor v1.0.0 // indirect github.com/go-git/gcfg v1.5.0 // indirect github.com/go-git/go-billy/v5 v5.3.1 // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/google/uuid v1.6.0 // indirect github.com/gotd/ige v0.2.2 // indirect github.com/gotd/neo v0.1.5 // indirect github.com/imdario/mergo v0.3.13 // indirect @@ -34,27 +41,34 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.15.9 // indirect - github.com/mattn/go-sqlite3 v1.14.15 // indirect + github.com/klauspost/compress v1.17.8 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.17 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect github.com/onsi/ginkgo v1.16.5 // indirect github.com/onsi/gomega v1.20.2 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/xanzy/ssh-agent v0.3.2 // indirect - go.opentelemetry.io/otel v1.9.0 // indirect - go.opentelemetry.io/otel/trace v1.9.0 // indirect - go.uber.org/atomic v1.10.0 // indirect - go.uber.org/multierr v1.8.0 // indirect - go.uber.org/zap v1.23.0 // indirect - golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect - golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b // indirect - golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect - golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect + go.opentelemetry.io/otel v1.26.0 // indirect + go.opentelemetry.io/otel/trace v1.26.0 // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.20.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - gorm.io/driver/sqlite v1.3.6 // indirect - gorm.io/gorm v1.23.8 // indirect - nhooyr.io/websocket v1.8.7 // indirect + gorm.io/driver/sqlite v1.5.5 // indirect + gorm.io/gorm v1.25.10 // indirect + modernc.org/libc v1.50.5 // indirect + modernc.org/mathutil v1.6.0 // indirect + modernc.org/memory v1.8.0 // indirect + modernc.org/sqlite v1.29.9 // indirect + nhooyr.io/websocket v1.8.11 // indirect rsc.io/qr v0.2.0 // indirect ) diff --git a/go.sum b/go.sum index 8ef7949..91154af 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/AnimeKaizoku/cacher v1.0.1 h1:rDjeDphztR4h234mnUxlOQWyYAB63WdzJB9zBg9HVPg= +github.com/AnimeKaizoku/cacher v1.0.1/go.mod h1:jw0de/b0K6W7Y3T9rHCMGVKUf6oG7hENNcssxYcZTCc= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= github.com/Microsoft/go-winio v0.4.16/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0= github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= @@ -13,17 +15,25 @@ github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKS github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= -github.com/anonyindian/gotgproto v1.0.0-beta08.0.20220813082126-f98d0f42e1d5 h1:fuTRG0eM5efhCWpFnyYeicZ1DZOkNS+3qOGKzOCgbXQ= -github.com/anonyindian/gotgproto v1.0.0-beta08.0.20220813082126-f98d0f42e1d5/go.mod h1:aG9WEU/7POJOUYh4a4SORPtAkwkIpt1ZUdfLSJrefdA= github.com/anonyindian/logger v1.0.0-alpha.3 h1:fYQFvadiiMI7hxW3VZNJXFzEWgmz/wgRB9tVey3oLDo= github.com/anonyindian/logger v1.0.0-alpha.3/go.mod h1:jb51uiKdlLOMtKakbyqsbrxTNr+Zt7qh2Va8sl5trTk= +github.com/anonyindian/logger v1.0.0-alpha.3.0.20220812175701-2dba945b21ba h1:wghouYpbw4fkc7Qv35HV7mFD62d241e8lqoHO+EM1c8= +github.com/anonyindian/logger v1.0.0-alpha.3.0.20220812175701-2dba945b21ba/go.mod h1:jb51uiKdlLOMtKakbyqsbrxTNr+Zt7qh2Va8sl5trTk= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bwesterb/go-ristretto v1.2.1/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/celestix/gotgproto v1.0.0-beta08.0.20220813082126-f98d0f42e1d5 h1:fuTRG0eM5efhCWpFnyYeicZ1DZOkNS+3qOGKzOCgbXQ= +github.com/celestix/gotgproto v1.0.0-beta08.0.20220813082126-f98d0f42e1d5/go.mod h1:aG9WEU/7POJOUYh4a4SORPtAkwkIpt1ZUdfLSJrefdA= +github.com/celestix/gotgproto v1.0.0-beta17 h1:iyP3redPfptDNPJbsf1ABtIn9IzzTGGOKJg/4HY3qPQ= +github.com/celestix/gotgproto v1.0.0-beta17/go.mod h1:05v7v0mls1WWNf3zzM6GyrN4LQKW3kopvc7yxYx62bg= +github.com/celestix/gotgproto v1.0.0-beta17.0.20240511154527-4b606be36214 h1:VjrwcQeNJLTJf3ndNmy47VjoeYjcKEPSVn4EsnFGbQ8= +github.com/celestix/gotgproto v1.0.0-beta17.0.20240511154527-4b606be36214/go.mod h1:osZOlN5irPByA0+3IPsZOH+Ibs0tOMSKmIdgGYEBRgE= github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/cloudflare/circl v1.1.0/go.mod h1:prBCrKB9DV4poKZY1l9zBXg2QJY7mvgRvtMxxK7fi4I= github.com/cloudflare/circl v1.2.0 h1:NheeISPSUcYftKlfrLuOo4T62FkmD4t4jviLfFFYaec= github.com/cloudflare/circl v1.2.0/go.mod h1:Ch2UgYr6ti2KTtlejELlROl0YIYj7SLjAC8M+INXlMk= @@ -31,6 +41,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= @@ -42,14 +54,24 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/glebarez/go-sqlite v1.22.0 h1:uAcMJhaA6r3LHMTFgP0SifzgXg46yJkgxqyuyec+ruQ= +github.com/glebarez/go-sqlite v1.22.0/go.mod h1:PlBIdHe0+aUEFn+r2/uthrWq4FxbzugL0L8Li6yQJbc= +github.com/glebarez/sqlite v1.11.0 h1:wSG0irqzP6VurnMEpFGer5Li19RpIRi2qvQz++w0GMw= +github.com/glebarez/sqlite v1.11.0/go.mod h1:h8/o8j5wiAsqSPoWELDUdJXhjAhsVliSn7bWZjOhrgQ= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-faster/errors v0.6.1 h1:nNIPOBkprlKzkThvS/0YaX8Zs9KewLCOSFQS5BU06FI= github.com/go-faster/errors v0.6.1/go.mod h1:5MGV2/2T9yvlrbhe9pD9LO5Z/2zCSq2T8j+Jpi2LAyY= +github.com/go-faster/errors v0.7.1 h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg= +github.com/go-faster/errors v0.7.1/go.mod h1:5ySTjWFiphBs07IKuiL69nxdfd5+fzh1u7FPGZP2quo= github.com/go-faster/jx v0.39.0 h1:5FmkTOHKKCsnAbSLzQclORDNndC9BY77UqB+HLsHDd0= github.com/go-faster/jx v0.39.0/go.mod h1:o7XQ3K95HwNxkBlrpUQIqjcXp4SmDIb9SyohdSVOeQs= +github.com/go-faster/jx v1.1.0 h1:ZsW3wD+snOdmTDy9eIVgQdjUpXRRV4rqW8NS3t+20bg= +github.com/go-faster/jx v1.1.0/go.mod h1:vKDNikrKoyUmpzaJ0OkIkRQClNHFX/nF3dnTJZb3skg= github.com/go-faster/xor v0.3.0 h1:tc0bdVe31Wj999e5rEj7K3DhHyQNp2VydYyLFj3YSN8= github.com/go-faster/xor v0.3.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ= +github.com/go-faster/xor v1.0.0 h1:2o8vTOgErSGHP3/7XwA5ib1FTtUsNtwCoLLBjl31X38= +github.com/go-faster/xor v1.0.0/go.mod h1:x5CaDY9UKErKzqfRfFZdfu+OSTfoZny3w5Ak7UxcipQ= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0/go.mod h1:5m20vg6GwYabIxaOonVkTdrILxQMpEShl1xiMF4ua+E= github.com/go-git/go-billy/v5 v5.2.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0= @@ -93,6 +115,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gotd/ige v0.2.2 h1:XQ9dJZwBfDnOGSTxKXBGP4gMud3Qku2ekScRjDWWfEk= @@ -101,6 +125,8 @@ github.com/gotd/neo v0.1.5 h1:oj0iQfMbGClP8xI59x7fE/uHoTJD7NZH9oV1WNuPukQ= github.com/gotd/neo v0.1.5/go.mod h1:9A2a4bn9zL6FADufBdt7tZt+WMhvZoc5gWXihOPoiBQ= github.com/gotd/td v0.68.1 h1:oxGqGFpntTJ73TpYhpglfEhTj95ozp7NC/4mRp7kWxU= github.com/gotd/td v0.68.1/go.mod h1:/JvwwlgnvqoO1bIXKFbt7BmZ7h9BySPCNWwXavFAxeA= +github.com/gotd/td v0.102.0 h1:V6zNba9FV21YiBm1t42ak5jyBFSQzY8+8fwZpOT5lGM= +github.com/gotd/td v0.102.0/go.mod h1:k9JQ7ktxOs4yTpE7X2ZvNtAl+blARhz1ak+Aw0VUHiQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= @@ -123,6 +149,8 @@ github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -137,15 +165,20 @@ github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= @@ -163,6 +196,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -188,16 +223,26 @@ github.com/xanzy/ssh-agent v0.3.2/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw= go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo= +go.opentelemetry.io/otel v1.26.0 h1:LQwgL5s/1W7YiiRwxf03QGnWLb2HW4pLiAhaA5cZXBs= +go.opentelemetry.io/otel v1.26.0/go.mod h1:UmLkJHUAidDval2EICqBMbnAd0/m2vmpf/dAM+fvFs4= go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc= go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo= +go.opentelemetry.io/otel/trace v1.26.0 h1:1ieeAUb4y0TE26jUFrCIXKpTuVK7uJGN9/Z/2LP5sQA= +go.opentelemetry.io/otel/trace v1.26.0/go.mod h1:4iDxvGDQuUkHve82hJJ8UqrwswHYsZuWCBllGV2U2y0= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= +go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -209,6 +254,8 @@ golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM= golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -220,12 +267,16 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b h1:ZmngSVLe/wycRns9MKikG9OWIEjGcGAkacif7oYQaUY= golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc= golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -253,6 +304,9 @@ golang.org/x/sys v0.0.0-20220315194320-039c03cc5b86/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY= golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -298,10 +352,23 @@ gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gorm.io/driver/sqlite v1.3.6 h1:Fi8xNYCUplOqWiPa3/GuCeowRNBRGTf62DEmhMDHeQQ= gorm.io/driver/sqlite v1.3.6/go.mod h1:Sg1/pvnKtbQ7jLXxfZa+jSHvoX8hoZA8cn4xllOMTgE= +gorm.io/driver/sqlite v1.5.5/go.mod h1:6NgQ7sQWAIFsPrJJl1lSNSu2TABh0ZZ/zm5fosATavE= gorm.io/gorm v1.23.4/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE= gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.25.10 h1:dQpO+33KalOA+aFYGlK+EfxcI5MbO7EP2yYygwh9h+s= +gorm.io/gorm v1.25.10/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= +modernc.org/libc v1.50.5 h1:ZzeUd0dIc/sUtoPTCYIrgypkuzoGzNu6kbEWj2VuEmk= +modernc.org/libc v1.50.5/go.mod h1:rhzrUx5oePTSTIzBgM0mTftwWHK8tiT9aNFUt1mldl0= +modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= +modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E= +modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU= +modernc.org/sqlite v1.29.9 h1:9RhNMklxJs+1596GNuAX+O/6040bvOwacTxuFcRuQow= +modernc.org/sqlite v1.29.9/go.mod h1:ItX2a1OVGgNsFh6Dv60JQvGfJfTPHPVpV6DF59akYOA= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nhooyr.io/websocket v1.8.11 h1:f/qXNc2/3DpoSZkHt1DQu6rj4zGC8JmkkLkWss0MgN0= +nhooyr.io/websocket v1.8.11/go.mod h1:rN9OFWIUwuxg4fR5tELlYC04bXYowCP9GX47ivo2l+c= rsc.io/qr v0.2.0 h1:6vBLea5/NRMVTz8V66gipeLycZMl/+UlFmk8DvqQ6WY= rsc.io/qr v0.2.0/go.mod h1:IF+uZjkb9fqyeF/4tlBoynqmQxUoPfWEKh921coOuXs= diff --git a/main.go b/main.go index 59af04c..bdd766e 100644 --- a/main.go +++ b/main.go @@ -1,25 +1,20 @@ package main import ( - "context" "flag" "os" "time" - "github.com/anonyindian/gotgproto" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/dispatcher/handlers/filters" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/generic" - "github.com/anonyindian/gotgproto/sessionMaker" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/dispatcher/handlers/filters" + "github.com/celestix/gotgproto/generic" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/config" "github.com/gigauserbot/giga/db" "github.com/gigauserbot/giga/modules" "github.com/gigauserbot/giga/utils" - "github.com/gotd/td/telegram" "github.com/gotd/td/telegram/dcs" "github.com/gotd/td/tg" ) @@ -57,55 +52,49 @@ func main() { func runClient(l *logger.Logger) { log := l.Create("CLIENT") - // custom dispatcher handles all the updates - dp := dispatcher.MakeDispatcher() - dp.AddHandlerToGroup(handlers.NewMessage(filters.Message.Text, utils.GetBotToken(l)), 2) - gotgproto.StartClient(&gotgproto.ClientHelper{ + + client, err := gotgproto.NewClient( // Get AppID from https://my.telegram.org/apps - AppID: config.ValueOf.AppId, + config.ValueOf.AppId, // Get ApiHash from https://my.telegram.org/apps - ApiHash: config.ValueOf.ApiHash, - // Session of your client - // sessionName: name of the session / session string in case of TelethonSession or StringSession - // sessionType: can be any out of Session, TelethonSession, StringSession. - Session: sessionMaker.NewSession(config.GetSessionString(), config.GetSessionType()), - // Make sure to specify custom dispatcher here in order to enjoy gotgproto's update handling - Dispatcher: dp, - // Add the handlers, post functions in TaskFunc - TaskFunc: func(ctx context.Context, client *telegram.Client) error { - go func() { - for { - if gotgproto.Sender != nil { - log.ChangeLevel(logger.LevelInfo).Println("STARTED") - break - } - } - ctx := ext.NewContext(ctx, client.API(), gotgproto.Self, gotgproto.Sender, &tg.Entities{}) - utils.TelegramClient = client - if *restartMsgId == 0 && *restartMsgText == "" { - utils.StartupAutomations(l, ctx, client) - } else { - generic.EditMessage(ctx, *restartChatId, &tg.MessagesEditMessageRequest{ - ID: *restartMsgId, - Message: *restartMsgText, - }) - } - // Modules shall not be loaded unless the setup is complete - modules.Load(l, dp) - helpmaker.MakeHelp() + config.ValueOf.ApiHash, + // ClientType, as we defined above + gotgproto.ClientTypePhone(""), + // Optional parameters of client + &gotgproto.ClientOpts{ + Session: config.GetSession(), + DisableCopyright: true, + DCList: func() (dct dcs.List) { if config.ValueOf.TestServer { - l.ChangeLevel(logger.LevelMain).Println("RUNNING ON TEST SERVER") + dct = dcs.Test() } - l.ChangeLevel(logger.LevelMain).Println("GIGA HAS BEEN STARTED") - }() - return nil + return + }(), }, - DisableCopyright: true, - DCList: func() (dct dcs.List) { - if config.ValueOf.TestServer { - dct = dcs.Test() - } - return - }(), - }) + ) + if err != nil { + log.Fatalln("failed to start client:", err) + } + log.ChangeLevel(logger.LevelInfo).Println("STARTED") + utils.TelegramClient = client.Client + config.Self = client.Self + dispatcher := client.Dispatcher + dispatcher.AddHandlerToGroup(handlers.NewMessage(filters.Message.Text, utils.GetBotToken(l)), 2) + ctx := client.CreateContext() + if *restartMsgId == 0 && *restartMsgText == "" { + utils.StartupAutomations(l, ctx, client) + } else { + generic.EditMessage(ctx, *restartChatId, &tg.MessagesEditMessageRequest{ + ID: *restartMsgId, + Message: *restartMsgText, + }) + } + // Modules shall not be loaded unless the setup is complete + modules.Load(l, dispatcher) + helpmaker.MakeHelp() + if config.ValueOf.TestServer { + l.ChangeLevel(logger.LevelMain).Println("RUNNING ON TEST SERVER") + } + l.ChangeLevel(logger.LevelMain).Println("GIGA HAS BEEN STARTED") + client.Idle() } diff --git a/modules/admin.go b/modules/admin.go index d3c68c4..01590c4 100644 --- a/modules/admin.go +++ b/modules/admin.go @@ -4,19 +4,18 @@ import ( "fmt" "html" - "github.com/anonyindian/gotgproto" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/parsemode/stylisehelper" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/parsemode/stylisehelper" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/utils" "github.com/gotd/td/telegram/message/styling" "github.com/gotd/td/tg" ) -func (m *module) LoadAdmin(dispatcher *dispatcher.CustomDispatcher) { +func (m *module) LoadAdmin(dispatcher dispatcher.Dispatcher) { var l = m.Logger.Create("ADMIN") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("admin", ` @@ -57,7 +56,7 @@ func ban(ctx *ext.Context, u *ext.Update) error { } else { text := stylisehelper.Start(styling.Plain("Successfully banned ")) text.Mention("this user", target).Plain(".") - builder := gotgproto.Sender.Self().Edit(u.EffectiveMessage.ID) + builder := ctx.Sender.Self().Edit(u.EffectiveMessage.ID) builder.StyledText(ctx, text.StoArray...) } return dispatcher.EndGroups @@ -86,7 +85,7 @@ func unban(ctx *ext.Context, u *ext.Update) error { } else { text := stylisehelper.Start(styling.Plain("Successfully unbanned ")) text.Mention("this user", target).Plain(".") - builder := gotgproto.Sender.Self().Edit(u.EffectiveMessage.ID) + builder := ctx.Sender.Self().Edit(u.EffectiveMessage.ID) builder.StyledText(ctx, text.StoArray...) } return dispatcher.EndGroups @@ -94,24 +93,24 @@ func unban(ctx *ext.Context, u *ext.Update) error { func del(ctx *ext.Context, u *ext.Update) error { chat := u.EffectiveChat() - reply := u.EffectiveMessage.ReplyTo.ReplyToMsgID - if reply == 0 { + reply, ok := u.EffectiveMessage.ReplyTo.(*tg.MessageReplyHeader) + if ok && reply.ReplyToMsgID == 0 { ctx.DeleteMessages(chat.GetID(), []int{u.EffectiveMessage.ID}) return dispatcher.EndGroups } - ctx.DeleteMessages(chat.GetID(), []int{u.EffectiveMessage.ID, reply}) + ctx.DeleteMessages(chat.GetID(), []int{u.EffectiveMessage.ID, reply.ReplyToMsgID}) return dispatcher.EndGroups } func purge(ctx *ext.Context, u *ext.Update) error { chat := u.EffectiveChat() - reply := u.EffectiveMessage.ReplyTo.ReplyToMsgID - if reply == 0 { + reply, ok := u.EffectiveMessage.ReplyTo.(*tg.MessageReplyHeader) + if ok && reply.ReplyToMsgID == 0 { ctx.DeleteMessages(chat.GetID(), []int{u.EffectiveMessage.ID}) return dispatcher.EndGroups } - toDel := []int{u.EffectiveMessage.ID, reply} - for i := reply; i < u.EffectiveMessage.ID; i++ { + toDel := []int{u.EffectiveMessage.ID, reply.ReplyToMsgID} + for i := reply.ReplyToMsgID; i < u.EffectiveMessage.ID; i++ { toDel = append(toDel, i) } ctx.DeleteMessages(chat.GetID(), toDel) diff --git a/modules/afk.go b/modules/afk.go index 0c8a2de..93d842a 100644 --- a/modules/afk.go +++ b/modules/afk.go @@ -5,21 +5,22 @@ import ( "html" "strings" - "github.com/anonyindian/gotgproto" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/dispatcher/handlers/filters" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/parsemode/stylisehelper" - "github.com/anonyindian/gotgproto/storage/cache" + "github.com/AnimeKaizoku/cacher" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/dispatcher/handlers/filters" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/parsemode/stylisehelper" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/db" "github.com/gotd/td/telegram/message/styling" "github.com/gotd/td/tg" ) -func (m *module) LoadAfk(dispatcher *dispatcher.CustomDispatcher) { +var afkCache = cacher.NewCacher[int64, bool](&cacher.NewCacherOpts{}) + +func (m *module) LoadAfk(dispatcher dispatcher.Dispatcher) { var l = m.Logger.Create("AFK") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("afk", ` @@ -33,7 +34,7 @@ func (m *module) LoadAfk(dispatcher *dispatcher.CustomDispatcher) { } func afk(ctx *ext.Context, u *ext.Update) error { - args := strings.Fields(u.EffectiveMessage.Message) + args := strings.Fields(u.EffectiveMessage.Text) chat := u.EffectiveChat() if len(args) > 1 { switch args[1] { @@ -83,14 +84,13 @@ func checkAfk(ctx *ext.Context, u *ext.Update) error { // Don't reply to bots ffs return nil } - if !(u.EffectiveMessage.Mentioned || (chat.IsAUser() && chat.GetID() != gotgproto.Self.ID)) { + if !(u.EffectiveMessage.Mentioned || (chat.IsAUser() && chat.GetID() != ctx.Self.ID)) { return nil } - afkCheckKey := fmt.Sprintf("afk-check-%d", user.ID) - if _, err := cache.Cache.Get(afkCheckKey); err == nil { + if _, ok := afkCache.Get(user.ID); ok { return nil } - go cache.Cache.Set(afkCheckKey, make([]byte, 0)) + afkCache.Set(user.ID, true) afk := db.GetAFK() if !afk.Toggle { return nil diff --git a/modules/help.go b/modules/help.go index 14ca535..bbbc475 100644 --- a/modules/help.go +++ b/modules/help.go @@ -3,16 +3,16 @@ package modules import ( "fmt" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" "github.com/gigauserbot/giga/bot" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gotd/td/tg" ) -func (m *module) LoadHelp(dispatcher *dispatcher.CustomDispatcher) { +func (m *module) LoadHelp(dispatcher dispatcher.Dispatcher) { var l = m.Logger.Create("HELP") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetMainHelp("The GIGA Userbot\n\nHere is the help menu:", "html") @@ -38,7 +38,7 @@ func helpCmd(ctx *ext.Context, u *ext.Update) error { }) switch { case chat.IsAChannel(): - ctx.Client.ChannelsDeleteMessages(ctx, &tg.ChannelsDeleteMessagesRequest{ + ctx.Raw.ChannelsDeleteMessages(ctx, &tg.ChannelsDeleteMessagesRequest{ Channel: &tg.InputChannel{ ChannelID: chat.GetID(), AccessHash: chat.GetAccessHash(), @@ -46,7 +46,7 @@ func helpCmd(ctx *ext.Context, u *ext.Update) error { ID: []int{u.EffectiveMessage.ID}, }) default: - ctx.Client.MessagesDeleteMessages(ctx, &tg.MessagesDeleteMessagesRequest{ + ctx.Raw.MessagesDeleteMessages(ctx, &tg.MessagesDeleteMessagesRequest{ Revoke: true, ID: []int{u.EffectiveMessage.ID}, }) diff --git a/modules/misc.go b/modules/misc.go index 61ea829..22072d6 100644 --- a/modules/misc.go +++ b/modules/misc.go @@ -7,21 +7,20 @@ import ( "strings" "time" - "github.com/anonyindian/gotgproto" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/dispatcher/handlers/filters" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/parsemode/entityhelper" - "github.com/anonyindian/gotgproto/types" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/dispatcher/handlers/filters" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/parsemode/entityhelper" + "github.com/celestix/gotgproto/types" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/db" "github.com/gigauserbot/giga/utils" "github.com/gotd/td/tg" ) -func (m *module) LoadMisc(dp *dispatcher.CustomDispatcher) { +func (m *module) LoadMisc(dp dispatcher.Dispatcher) { var l = m.Logger.Create("MISC") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("misc", ` @@ -43,9 +42,9 @@ func (m *module) LoadMisc(dp *dispatcher.CustomDispatcher) { func jsonify(ctx *ext.Context, u *ext.Update) error { chat := u.EffectiveChat() msg := u.EffectiveMessage - if id := msg.ReplyTo.ReplyToMsgID; id != 0 { + if reply, ok := msg.ReplyTo.(*tg.MessageReplyHeader); ok && reply.ReplyToMsgID != 0 { m, err := ctx.GetMessages(chat.GetID(), []tg.InputMessageClass{&tg.InputMessageID{ - ID: id, + ID: reply.ReplyToMsgID, }}) if err != nil { ctx.EditMessage(chat.GetID(), &tg.MessagesEditMessageRequest{ @@ -56,7 +55,7 @@ func jsonify(ctx *ext.Context, u *ext.Update) error { } md, ok := m[0].(*tg.Message) if ok { - msg = md + msg = types.ConstructMessage(md) } } b, err := json.MarshalIndent(msg, "", " ") @@ -103,7 +102,7 @@ func ping(ctx *ext.Context, u *ext.Update) error { } func tagLogger(ctx *ext.Context, u *ext.Update) error { - args := strings.Fields(u.EffectiveMessage.Message) + args := strings.Fields(u.EffectiveMessage.Text) chat := u.EffectiveChat() if len(args) > 1 { switch args[1] { @@ -143,7 +142,7 @@ func checkTags(ctx *ext.Context, u *ext.Update) error { if user != nil && user.Bot { return nil } - if !(u.EffectiveMessage.Mentioned || (chat.IsAUser() && chat.GetID() != gotgproto.Self.ID)) { + if !(u.EffectiveMessage.Mentioned || (chat.IsAUser() && chat.GetID() != ctx.Self.ID)) { return nil } if !db.GetTagLogger() { diff --git a/modules/modules.go b/modules/modules.go index 2898726..fe8fa10 100644 --- a/modules/modules.go +++ b/modules/modules.go @@ -3,17 +3,17 @@ package modules import ( "reflect" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" ) type module struct { Logger *logger.Logger } -func Load(l *logger.Logger, dispatcher *dispatcher.CustomDispatcher) { +func Load(l *logger.Logger, dispatcher dispatcher.Dispatcher) { l = l.Create("MODULES") defer l.ChangeLevel(logger.LevelMain).Println("LOADED") Type := reflect.TypeOf(&module{l}) diff --git a/modules/prog.go b/modules/prog.go index 57f2c70..03cb6e1 100644 --- a/modules/prog.go +++ b/modules/prog.go @@ -3,16 +3,16 @@ package modules import ( "os" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/utils" "github.com/gotd/td/tg" ) -func (m *module) LoadProg(dispatcher *dispatcher.CustomDispatcher) { +func (m *module) LoadProg(dispatcher dispatcher.Dispatcher) { var l = m.Logger.Create("PROG") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("prog", ` diff --git a/modules/shell.go b/modules/shell.go index bcfb2cf..60027c6 100644 --- a/modules/shell.go +++ b/modules/shell.go @@ -5,10 +5,10 @@ import ( "os/exec" "strings" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gotd/td/tg" ) @@ -25,7 +25,7 @@ func Shellout(command string) (error, string, string) { return err, stdout.String(), stderr.String() } -func (m *module) LoadShell(dispatcher *dispatcher.CustomDispatcher) { +func (m *module) LoadShell(dispatcher dispatcher.Dispatcher) { var l = m.Logger.Create("SHELL") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("shell", "help") @@ -35,7 +35,7 @@ func (m *module) LoadShell(dispatcher *dispatcher.CustomDispatcher) { func sh(ctx *ext.Context, u *ext.Update) error { chat := u.EffectiveChat() // msg := u.EffectiveMessage - cmd := strings.Fields(u.EffectiveMessage.Message) + cmd := strings.Fields(u.EffectiveMessage.Text) if len(cmd) == 1 { _, err := ctx.EditMessage(chat.GetID(), &tg.MessagesEditMessageRequest{ ID: u.EffectiveMessage.ID, diff --git a/modules/update.go b/modules/update.go index 394903f..bfe7a94 100644 --- a/modules/update.go +++ b/modules/update.go @@ -3,17 +3,17 @@ package modules import ( "fmt" - "github.com/anonyindian/gotgproto/dispatcher" - "github.com/anonyindian/gotgproto/dispatcher/handlers" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/parsemode/entityhelper" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto/dispatcher" + "github.com/celestix/gotgproto/dispatcher/handlers" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/parsemode/entityhelper" "github.com/gigauserbot/giga/bot/helpmaker" "github.com/gigauserbot/giga/utils" "github.com/gotd/td/tg" ) -func (m *module) LoadUpdate(dp *dispatcher.CustomDispatcher) { +func (m *module) LoadUpdate(dp dispatcher.Dispatcher) { var l = m.Logger.Create("UPDATER") defer l.ChangeLevel(logger.LevelInfo).Println("LOADED") helpmaker.SetModuleHelp("updater", ` diff --git a/utils/extract.go b/utils/extract.go index 246d4a4..a70b88c 100644 --- a/utils/extract.go +++ b/utils/extract.go @@ -4,16 +4,16 @@ import ( "errors" "strings" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/types" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/types" "github.com/gotd/td/tg" ) -func ExtractUser(ctx *ext.Context, msg *tg.Message, chat types.EffectiveChat) (target int64, err error) { - if id := msg.ReplyTo.ReplyToMsgID; id != 0 { +func ExtractUser(ctx *ext.Context, msg *types.Message, chat types.EffectiveChat) (target int64, err error) { + if reply, ok := msg.ReplyTo.(*tg.MessageReplyHeader); ok && reply.ReplyToMsgID != 0 { var m []tg.MessageClass m, err = ctx.GetMessages(chat.GetID(), []tg.InputMessageClass{&tg.InputMessageID{ - ID: id, + ID: reply.ReplyToMsgID, }}) if err != nil { return @@ -24,7 +24,7 @@ func ExtractUser(ctx *ext.Context, msg *tg.Message, chat types.EffectiveChat) (t } } if target == 0 { - args := strings.Fields(msg.Message) + args := strings.Fields(msg.Text) if !(len(args) > 1 && strings.HasPrefix(args[1], "@")) { err = errors.New("no user provided") return diff --git a/utils/startup.go b/utils/startup.go index e4fce6e..3276aa0 100644 --- a/utils/startup.go +++ b/utils/startup.go @@ -6,11 +6,11 @@ import ( "strings" "time" - "github.com/anonyindian/gotgproto" - "github.com/anonyindian/gotgproto/ext" - "github.com/anonyindian/gotgproto/storage" - "github.com/anonyindian/gotgproto/types" "github.com/anonyindian/logger" + "github.com/celestix/gotgproto" + "github.com/celestix/gotgproto/ext" + "github.com/celestix/gotgproto/storage" + "github.com/celestix/gotgproto/types" "github.com/gigauserbot/giga/bot" "github.com/gigauserbot/giga/config" "github.com/gigauserbot/giga/db" @@ -26,11 +26,13 @@ var ( ) // StartupAutomations includes the stuff to be done on each startup -func StartupAutomations(l *logger.Logger, ctx *ext.Context, client *telegram.Client) { +func StartupAutomations(l *logger.Logger, ctx *ext.Context, client *gotgproto.Client) { if group := setupLogsGroup(ctx, client); group != 0 { _, err := ctx.SendMessage(group, &tg.MessagesSendMessageRequest{ - Message: "Your GIGA is alive!", - ReplyToMsgID: trySendingFile(ctx, group), + Message: "Your GIGA is alive!", + ReplyTo: &tg.InputReplyToMessage{ + ReplyToMsgID: trySendingFile(ctx, group), + }, }) if err != nil { // check err in string because unwrapping didn't work @@ -54,7 +56,7 @@ func StartupAutomations(l *logger.Logger, ctx *ext.Context, client *telegram.Cli bot.Username = b.Username bot.StartClient(l, b) } else if db.GetSettings().Token == "" { - uname := setupBot(ctx, client, nil) + uname := setupBot(ctx, nil) if uname == "BOT_NOT_CREATED" { fmt.Println("failed to create bot") return @@ -79,7 +81,7 @@ func StartupAutomations(l *logger.Logger, ctx *ext.Context, client *telegram.Cli var TOKEN_REGEXP = regexp.MustCompile(`(\d+:[a-zA-Z0-9_\-]+)`) -func setupBot(ctx *ext.Context, client *telegram.Client, u types.EffectiveChat) string { +func setupBot(ctx *ext.Context, u types.EffectiveChat) string { if u == nil { u, _ = ctx.ResolveUsername("botfather") } @@ -88,12 +90,13 @@ func setupBot(ctx *ext.Context, client *telegram.Client, u types.EffectiveChat) Message: "/cancel", }) if err != nil && strings.Contains(err.Error(), "YOU_BLOCKED_USER") { - if ok, _ := ctx.Client.ContactsUnblock(ctx, &tg.InputPeerUser{ - UserID: u.GetID(), - AccessHash: u.GetAccessHash(), + if ok, _ := ctx.Raw.ContactsBlock(ctx, &tg.ContactsBlockRequest{ + ID: &tg.InputPeerUser{ + UserID: u.GetID(), + AccessHash: u.GetAccessHash(), + }, }); ok { - return setupBot(ctx, client, u) - + return setupBot(ctx, u) } } time.Sleep(time.Second) @@ -105,7 +108,7 @@ func setupBot(ctx *ext.Context, client *telegram.Client, u types.EffectiveChat) Message: "GIGA Helper Bot", }) time.Sleep(time.Second * 1) - uname := fmt.Sprintf("@GIGA_%s%dbot", string(gotgproto.Self.FirstName[0]), time.Now().Unix()) + uname := fmt.Sprintf("@GIGA_%s%dbot", string(ctx.Self.FirstName[0]), time.Now().Unix()) ctx.SendMessage(u.GetID(), &tg.MessagesSendMessageRequest{ Message: uname, }) @@ -129,25 +132,28 @@ func setupBot(ctx *ext.Context, client *telegram.Client, u types.EffectiveChat) return uname } -func setupLogsGroup(ctx *ext.Context, client *telegram.Client) int64 { +func setupLogsGroup(ctx *ext.Context, client *gotgproto.Client) int64 { if group := db.GetSettings().LogsGroup; group != 0 { return group } u, _ := ctx.ResolveUsername("GIGAubot") - upd, _ := client.API().MessagesCreateChat(ctx, &tg.MessagesCreateChatRequest{ + ivs, err := client.API().MessagesCreateChat(ctx, &tg.MessagesCreateChatRequest{ Users: []tg.InputUserClass{&tg.InputUser{ UserID: u.GetID(), AccessHash: u.GetAccessHash(), }}, Title: "GIGA Userbot Logs", }) - update, ok := upd.(*tg.Updates) + if err != nil { + return 0 + } + update, ok := ivs.Updates.(*tg.Updates) if !ok { return 0 } group := update.Chats[0].GetID() // Add created group's peer to storage coz gotgproto still doesn't do that :P - storage.AddPeer(group, storage.DefaultAccessHash, storage.TypeChat, storage.DefaultUsername) + client.PeerStorage.AddPeer(group, storage.DefaultAccessHash, storage.TypeChat, storage.DefaultUsername) db.UpdateLogs(group) return group } @@ -161,13 +167,13 @@ func GetBotToken(l *logger.Logger) func(ctx *ext.Context, u *ext.Update) error { if chat.GetID() != BotFatherId { return nil } - if !TOKEN_REGEXP.MatchString(u.EffectiveMessage.Message) { + if !TOKEN_REGEXP.MatchString(u.EffectiveMessage.Text) { return nil } - token := TOKEN_REGEXP.FindString(u.EffectiveMessage.Message) + token := TOKEN_REGEXP.FindString(u.EffectiveMessage.Text) b, err := bot.MakeBot(token) if err != nil { - uname := setupBot(ctx, TelegramClient, nil) + uname := setupBot(ctx, nil) if uname == "BOT_NOT_CREATED" { return nil } @@ -184,7 +190,7 @@ func GetBotToken(l *logger.Logger) func(ctx *ext.Context, u *ext.Update) error { } func trySendingFile(ctx *ext.Context, chatId int64) int { - upload := uploader.NewUploader(ctx.Client) + upload := uploader.NewUploader(ctx.Raw) f, err := upload.FromPath(ctx, "assets/giga.webp") if err != nil { return 0