New karma, fixed docsearch

This commit is contained in:
nefrace 2023-09-14 01:46:42 +03:00
parent 79d4ed3540
commit 5f3a24ebd9
11 changed files with 197 additions and 127 deletions

View File

@ -10,7 +10,8 @@ var commandSay = neco.NewCommand("say", "Пишу ваш текст от сво
var commandFeed = neco.NewCommand("subscribe", "Регистрирую данный чат в качестве получателя рассылки", true)
var commandFeedUnsub = neco.NewCommand("unsubscribe", "Удаляю данный чат из рассылки", true)
var commandTop = neco.NewCommand("top", "Показываю ТОП-10 пользователей по числу кармы", false)
var commandBottom = neco.NewCommand("top", "Показываю отрицательный ТОП-10 пользователей по числу кармы", false)
var defaultCommands = []*neco.Command{commandHelp, commandMe, commandTop}
var defaultCommands = []*neco.Command{commandHelp, commandMe, commandTop, commandBottom}
var adminCommands = []*neco.Command{commandSay, commandFeed, commandFeed, commandFeedUnsub}
var allCommands = append(defaultCommands, adminCommands...)

17
go.mod
View File

@ -3,32 +3,31 @@ module git.nefrace.ru/nefrace/godette
go 1.20
require (
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615140409-57d11c7671ae
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615220714-9e122d1a128b
git.nefrace.ru/nefrace/tongo v0.0.0-20230604223535-44cc124fb18a
github.com/NicoNex/echotron/v3 v3.25.1
github.com/google/uuid v1.3.0
github.com/NicoNex/echotron/v3 v3.26.0
github.com/joho/godotenv v1.5.1
github.com/mmcdole/gofeed v1.2.1
go.mongodb.org/mongo-driver v1.11.7
go.mongodb.org/mongo-driver v1.12.1
)
require (
github.com/PuerkitoBio/goquery v1.8.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.16.6 // indirect
github.com/klauspost/compress v1.16.7 // indirect
github.com/mmcdole/goxpp v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect
golang.org/x/crypto v0.10.0 // indirect
golang.org/x/net v0.11.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/text v0.10.0 // indirect
golang.org/x/text v0.12.0 // indirect
)

65
go.sum
View File

@ -1,42 +1,32 @@
git.nefrace.ru/nefrace/nechotron v0.0.0-20230119201747-5842815c958c h1:3vYJhrChrFYfNPzluBI4qVilixJTC1qURVqcaQYfPIA=
git.nefrace.ru/nefrace/nechotron v0.0.0-20230119201747-5842815c958c/go.mod h1:PiYTWTy1SMXKdsxNSrQOqUQRffw4DXI32PjjxVMJuOA=
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615140409-57d11c7671ae h1:2nCSqiPJ1CzddWLPRGurWvmR1eQ/34qTOt/Dgqf1eJI=
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615140409-57d11c7671ae/go.mod h1:vgTeasz5ox8uDa+mT4FuYSkMABJAA+VNp9umco7rdac=
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615220714-9e122d1a128b h1:aVGf1ujXGuPBYjspWJ5/ZqEkmiEWE8wJUZoS9fXorl4=
git.nefrace.ru/nefrace/nechotron v0.0.0-20230615220714-9e122d1a128b/go.mod h1:OWYZFD8b0vBZVZCYpKG3UdEX6+eth1QMwBTCayHJk6A=
git.nefrace.ru/nefrace/tongo v0.0.0-20230604223535-44cc124fb18a h1:rzWY7QiyuOMxTl6oMqkh2xi6m4KmNO2edZi8idmB57I=
git.nefrace.ru/nefrace/tongo v0.0.0-20230604223535-44cc124fb18a/go.mod h1:QfvcElrkpZQAXeDzEEVh9fbViVFYS/ZOsn8Zvu6cTcg=
github.com/NicoNex/echotron/v3 v3.22.0 h1:2ymJcjKqtZ/rfD5CveR2VKqQob7JmRgJmoLOJ3sim/4=
github.com/NicoNex/echotron/v3 v3.22.0/go.mod h1:LpP5IyHw0y+DZUZMBgXEDAF9O8feXrQu7w7nlJzzoZI=
github.com/NicoNex/echotron/v3 v3.25.1 h1:0PZjtZpcGHNp3OVxhkcq6hZWz9zGjyNAWeA5Jo+bUig=
github.com/NicoNex/echotron/v3 v3.25.1/go.mod h1:LpP5IyHw0y+DZUZMBgXEDAF9O8feXrQu7w7nlJzzoZI=
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/NicoNex/echotron/v3 v3.26.0 h1:kNO9AD0CNXAlbd96Z4jT8NHcn2OPD3wTXs6HnjXHXU0=
github.com/NicoNex/echotron/v3 v3.26.0/go.mod h1:LpP5IyHw0y+DZUZMBgXEDAF9O8feXrQu7w7nlJzzoZI=
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
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/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.16.6 h1:91SKEy4K37vkp255cJ8QesJhjyRO0hn9i9G0GoUwLsk=
github.com/klauspost/compress v1.16.6/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I=
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
github.com/mmcdole/gofeed v1.2.1 h1:tPbFN+mfOLcM1kDF1x2c/N68ChbdBatkppdzf/vDe1s=
github.com/mmcdole/gofeed v1.2.1/go.mod h1:2wVInNpgmC85q16QTTuwbuKxtKkHLCDDtf0dCmnrNr4=
github.com/mmcdole/goxpp v1.1.0 h1:WwslZNF7KNAXTFuzRtn/OKZxFLJAAyOA9w82mDz2ZGI=
@ -49,33 +39,29 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE=
github.com/montanaflynn/stats v0.7.1/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow=
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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY=
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8=
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk=
github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/R083muKhosV54bj5niojjWZvU8xrevuH4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.mongodb.org/mongo-driver v1.11.7 h1:LIwYxASDLGUg/8wOhgOOZhX8tQa/9tgZPgzZoVqJvcs=
go.mongodb.org/mongo-driver v1.11.7/go.mod h1:G9TgswdsWjX4tmDA5zfs2+6AEPpYJwqblyjsfuh8oXY=
go.mongodb.org/mongo-driver v1.12.1 h1:nLkghSU8fQNaK7oUmDhQFsnrtcoNy7Z6LVFKsEecqgE=
go.mongodb.org/mongo-driver v1.12.1/go.mod h1:/rGBTebI3XYboVmgz+Wv3Bcbl3aD0QF9zl6kDDw18rQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
@ -84,15 +70,12 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU=
golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
@ -115,19 +98,15 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -7,6 +7,7 @@ import (
"net/http"
"net/url"
"strings"
"time"
"git.nefrace.ru/nefrace/nechotron"
"github.com/NicoNex/echotron/v3"
@ -14,6 +15,7 @@ import (
var docApiURL = "https://docs.godotengine.org/_/api/v2/search/?q=%s&project=godot&version=%s&language=en"
var docURL = "https://docs.godotengine.org/en/%s/search.html?q=%s"
var lastDocSearch = time.Now()
type DocResponse struct {
Count uint `json:"count"`
@ -33,22 +35,45 @@ type DocHighlights struct {
Title []string `json:"title"`
}
func getDocs(topic string, version string) (string, error) {
topic_escaped := nechotron.EscapeMd2(topic)
not_found := fmt.Sprintf("Извините, по запросу *%s* ничего не найдено.", topic_escaped)
req, err := url.ParseRequestURI(fmt.Sprintf(docApiURL, url.QueryEscape(topic), version))
func getAndDecode[T any](u string) (*T, error) {
req, err := url.ParseRequestURI(u)
if err != nil {
return not_found, err
log.Println("Can't parse url: ", err)
return nil, err
}
result, err := http.Get(req.String())
if err != nil {
return not_found, err
log.Println("Can't get http: ", err)
return nil, err
}
defer result.Body.Close()
var response DocResponse
var response T
err = json.NewDecoder(result.Body).Decode(&response)
if err != nil {
return not_found, err
return nil, err
}
return &response, nil
}
func getDocs(topic string, version string) (string, string, error) {
since := time.Since(lastDocSearch)
if since < 20*time.Second {
return "Извините, запросы происходят слишком часто\\.", "", nil
}
lastDocSearch = time.Now()
topic_escaped := nechotron.EscapeMd2(topic)
not_found := fmt.Sprintf("Извините, по запросу *%s* ничего не найдено\\.", topic_escaped)
exactUrl := fmt.Sprintf(docApiURL, url.QueryEscape(topic), version)
looselyUrl := fmt.Sprintf(docApiURL, url.QueryEscape(topic+"*"), version)
workedTopic := topic
response, err := getAndDecode[DocResponse](exactUrl)
if err != nil || len(response.Results) == 0 {
workedTopic = topic + "*"
response, err = getAndDecode[DocResponse](looselyUrl)
if err != nil || len(response.Results) == 0 {
return not_found, "", nil
}
}
textResults := ""
for i, r := range response.Results {
@ -60,10 +85,10 @@ func getDocs(topic string, version string) (string, error) {
textResults += fmt.Sprintf("%d\\. [%s](%s)\n", i+1, text, link)
}
text := fmt.Sprintf("Вот что я нашла по запросу *%s* \\(для версии `%s`\\): \n\n%s", topic_escaped, version, textResults)
return text, nil
return text, workedTopic, nil
}
var doc_variants []string = []string{"latest", "3.5"}
var doc_variants []string = []string{"4.1", "3.5"}
func handleDocRequest(u *nechotron.Update) error {
topic := u.Ctx.Value(nechotron.FilteredValue("docTopic")).(string)
@ -75,9 +100,13 @@ func handleDocRequest(u *nechotron.Update) error {
}
versionButtons = append(versionButtons, nechotron.InButtonCallback("Для "+variant, fmt.Sprintf("docs:%s:%s", variant, topic)))
}
text, workedTopic, docerr := getDocs(topic, doc_variants[0])
if docerr != nil {
log.Println("Can't get docs: ", docerr)
}
kb := nechotron.NewInlineKeyboard().
Row(versionButtons...).
Row(nechotron.InButtonURL("Поищу сам", fmt.Sprintf(docURL, currentVersion, url.QueryEscape(topic)))).
Row(nechotron.InButtonURL("Поискать самостоятельно", fmt.Sprintf(docURL, currentVersion, url.QueryEscape(workedTopic)))).
Row(nechotron.InButtonCallback("Спасибо, не надо", "delete"))
opts := nechotron.NewOptions().
MarkdownV2().
@ -85,10 +114,6 @@ func handleDocRequest(u *nechotron.Update) error {
ReplyMarkup(kb.Markup()).
MessageOptions()
text, docerr := getDocs(topic, "latest")
if docerr != nil {
log.Println("Can't get docs: ", docerr)
}
_, err := u.AnswerText(text, opts)
return err
}
@ -105,19 +130,23 @@ func handleDocCallback(u *nechotron.Update) error {
}
versionButtons = append(versionButtons, nechotron.InButtonCallback("Для "+variant, fmt.Sprintf("docs:%s:%s", variant, topic)))
}
text, workedTopic, docerr := getDocs(topic, version)
if docerr != nil {
log.Println("Can't get docs: ", docerr)
}
kb := nechotron.NewInlineKeyboard().
Row(versionButtons...).
Row(nechotron.InButtonURL("Поищу сам", fmt.Sprintf(docURL, version, url.QueryEscape(topic)))).
Row(nechotron.InButtonURL("Поискать самостоятельно", fmt.Sprintf(docURL, version, url.QueryEscape(workedTopic)))).
Row(nechotron.InButtonCallback("Спасибо, не надо", "delete"))
opts := nechotron.NewOptions().
MarkdownV2().
ReplyMarkup(kb.Markup()).
MessageTextOptions()
text, docerr := getDocs(topic, version)
if docerr != nil {
log.Println("Can't get docs: ", docerr)
}
_, err := u.EditText(text, opts)
if err != nil {
log.Println(err)
log.Println(text)
}
return err
}

View File

@ -1,8 +1,11 @@
package main
import (
"bytes"
"errors"
"fmt"
"html/template"
"math/rand"
"time"
"git.nefrace.ru/nefrace/nechotron"
@ -18,6 +21,14 @@ func GetTriggers() map[string]int {
}
}
type KarmaMessageData struct {
UserTo string
UserFrom string
Change string
KarmaFrom int64
KarmaTo int64
}
func handleKarma(u *nechotron.Update) error {
from, _ := u.Ctx.Value("userfrom").(*User)
to, _ := u.Ctx.Value("userto").(*User)
@ -35,11 +46,12 @@ func handleKarma(u *nechotron.Update) error {
value := u.Ctx.Value(nechotron.FilteredValue("karmaValue")).(int)
// trigger := u.Ctx.Value(nechotron.FilteredValue("karmaTrigger")).(string)
store := tongo.NewStore[KarmaShot](db)
fromKarma, _ := store.Count(u.Ctx, tongo.E("to", from.ID))
totalFromKarma := from.KarmaOffset + fromKarma
userStore := tongo.NewStore[User](db)
tmplStore := tongo.NewStore[KarmaMessage](db)
totalFromKarma := from.Karma
if totalFromKarma <= 0 {
res, err := u.AnswerText(
fmt.Sprintf("У тебя слишком маленькая карма *\\(%d\\), чтобы менять её другим\\.", totalFromKarma),
fmt.Sprintf("У тебя слишком маленькая карма *\\(%d\\)*, чтобы менять её другим\\.", totalFromKarma),
&echotron.MessageOptions{ParseMode: echotron.MarkdownV2, ReplyToMessageID: u.MessageID()})
go waitAndDelete(u, u.ChatID(), res.Result.ID)
return err
@ -56,7 +68,7 @@ func handleKarma(u *nechotron.Update) error {
if recentShots > 0 {
// u.DeleteMessage()
res, err := u.AnswerMarkdown(
fmt.Sprintf("*%s*, ты только недавно менял карму *%s*\\. Подожди минуту\\.", mentionFrom, mentionTo))
fmt.Sprintf("*%s*, вы только недавно меняли карму *%s*\\. Подождите минуту\\.", mentionFrom, mentionTo))
go waitAndDelete(u, u.ChatID(), res.Result.ID)
return err
}
@ -78,14 +90,52 @@ func handleKarma(u *nechotron.Update) error {
Count: value,
}
store.InsertOne(u.Ctx, &newShot)
newKarma, _ := store.Count(u.Ctx, tongo.E("to", to.ID))
totalToKarma := to.KarmaOffset + newKarma
changeText := "повысил"
if value < 0 {
changeText = "понизил"
to.Karma += int64(value)
userStore.Coll.UpdateByID(
u.Ctx,
to.Id,
tongo.D(
tongo.E(
"$set", tongo.D(
tongo.E("karmaoffset", to.Karma),
),
),
),
)
totalToKarma := to.Karma
textTemplate := "Карма *{{.UserTo}} \\(теперь {{.KarmaTo}}\\)* была {{.Change}} *{{.UserFrom}} \\({{.KarmaFrom}}\\)*"
changeUp := "повышена"
changeDown := "понижена"
tmpls, err := tmplStore.GetMany(u.Ctx)
if err == nil && len(tmpls) > 0 {
tmp := tmpls[rand.Intn(len(tmpls))]
changeUp = tmp.WordPlus
changeDown = tmp.WordMinus
textTemplate = tmp.Template
}
_, err = u.AnswerMarkdown(
fmt.Sprintf("*%s \\(%d\\)* только что %s карму *%s \\(%d\\)*", mentionFrom, totalFromKarma, changeText, mentionTo, totalToKarma))
changeText := changeUp
if value < 0 {
changeText = changeDown
}
tmpl, err := template.New("karmatext").Parse(textTemplate)
if err != nil {
return errors.Join(fmt.Errorf("can't parse karma template: %s", textTemplate), err)
}
data := KarmaMessageData{
UserTo: mentionTo,
UserFrom: mentionFrom,
KarmaTo: totalToKarma,
KarmaFrom: totalFromKarma,
Change: changeText,
}
var buf bytes.Buffer
err = tmpl.Execute(&buf, data)
if err != nil {
return errors.Join(errors.New("can't execute karma template"), err)
}
_, err = u.AnswerMarkdown(buf.String())
return err
}
@ -103,7 +153,7 @@ func handleTop(u *nechotron.Update, _ string) error {
}
text := ""
for n, u := range users {
text += fmt.Sprintf("%d \\- %s \\(%d\\)\n", n, nechotron.EscapeMd2(u.Name), u.TotalKarma)
text += fmt.Sprintf("%d \\- %s \\(%d\\)\n", n, nechotron.EscapeMd2(u.Name), u.Karma)
}
text = fmt.Sprintf(topText, text)
u.AnswerMarkdown(text)

View File

@ -1,10 +1,11 @@
package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"log"
"math/rand"
"time"
"git.nefrace.ru/nefrace/nechotron"
@ -16,7 +17,10 @@ import (
func handleMe(u *nechotron.Update, text string) error {
u.DeleteMessage()
_, err := u.AnswerMarkdown(fmt.Sprintf("_*%s* %s_", nechotron.EscapeMd2(u.From().FirstName), nechotron.EscapeMd2(text)))
return err
if err != nil {
return errors.Join(fmt.Errorf("can't handle /me: %s", u.Text()), err)
}
return nil
}
var helpText = `
@ -28,7 +32,10 @@ var helpText = `
func handleHelp(u *nechotron.Update, text string) error {
commands := nechotron.MakeCommandList("`%s` \\- _%s_\n", commandHelp, commandMe)
_, err := u.AnswerMarkdown(fmt.Sprintf(helpText, commands, BuildTime))
return err
if err != nil {
return errors.Join(fmt.Errorf("can't handle /help: %s", u.Text()), err)
}
return nil
}
func handleSay(u *nechotron.Update, text string) error {
@ -37,30 +44,9 @@ func handleSay(u *nechotron.Update, text string) error {
return nil
}
_, err := u.AnswerMarkdown(fmt.Sprintf("*_%s_*", nechotron.EscapeMd2(text)))
return err
}
func handleOfftop(u *nechotron.Update) error {
text := "Держите [ссылку на оффтоп](%s)\\!"
offtopLink := "https://t.me/Godot_Engine_Offtop"
offtopAnswers, err := tongo.NewStore[TriggerText](db).GetMany(u.Ctx, tongo.E("trigger", "offtop"))
if err == nil {
if len(offtopAnswers) > 0 {
text = offtopAnswers[rand.Intn(len(offtopAnswers)-1)].Text
}
if err != nil {
return errors.Join(fmt.Errorf("can't handle /say: %s", u.Text()), err)
}
offtopUrl, err := tongo.NewStore[Config](db).GetOne(u.Ctx, tongo.E("name", "offtop_url"))
if err == nil {
offtopLink = offtopUrl.Value.(string)
}
text = fmt.Sprintf(text, offtopLink)
kb := nechotron.NewInlineKeyboard().Row(nechotron.InButtonCallback("Спасибо, не надо", "delete")).Markup()
opts := nechotron.NewOptions().
MarkdownV2().
ReplyTo(u.MessageID()).
ReplyMarkup(kb).
MessageOptions()
u.AnswerText(text, opts)
return nil
}
@ -78,6 +64,8 @@ func handleUsersImport(u *nechotron.Update) error {
if err != nil {
u.AnswerPlain(err.Error())
}
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
store := tongo.NewStore[User](db)
for _, user := range users {
if user.MessagesCount == 0 {
@ -85,13 +73,13 @@ func handleUsersImport(u *nechotron.Update) error {
}
log.Printf("%+v", user)
newUser := User{
Item: tongo.NewID(),
Username: user.Username,
Name: user.Name,
ID: user.ID,
KarmaOffset: user.Karma,
Item: tongo.NewID(),
Username: user.Username,
Name: user.Name,
ID: user.ID,
Karma: user.Karma,
}
_, err := store.InsertOne(u.Ctx, &newUser)
_, err := store.InsertOne(ctx, &newUser)
if err != nil {
log.Println(err)
}

View File

@ -2,6 +2,7 @@ package main
import (
"context"
"errors"
"log"
"time"
@ -70,14 +71,14 @@ func UserDBUpdater(db *tongo.Database) nechotron.Middleware {
from := u.From()
userFrom, err := UpdateUser(u.Ctx, db, from, true)
if err != nil {
return err
return errors.Join(errors.New("can't update from-user"), err)
}
u.Ctx = context.WithValue(u.Ctx, "userfrom", userFrom)
if u.IsMessage() && u.Message.ReplyToMessage != nil {
to := u.Message.ReplyToMessage.From
userTo, err := UpdateUser(u.Ctx, db, to, false)
if err != nil {
return err
return errors.Join(errors.New("can't update to-user"), err)
}
u.Ctx = context.WithValue(u.Ctx, "userto", userTo)
}

7
rss.go
View File

@ -22,7 +22,7 @@ _%s_
func RSSTask(api *echotron.API) {
for {
ParseRSS(api)
time.Sleep(5 * time.Minute)
time.Sleep(20 * time.Minute)
}
}
@ -67,9 +67,12 @@ func ParseRSS(api *echotron.API) {
)
sent := false
for _, chat := range chats {
_, err := api.SendPhoto(echotron.NewInputFileURL(item.Custom["image"]), chat.ChatID, nechotron.NewOptions().MarkdownV2().Caption(text).PhotoOptions())
res, err := api.SendPhoto(echotron.NewInputFileURL(item.Custom["image"]), chat.ChatID, nechotron.NewOptions().MarkdownV2().Caption(text).PhotoOptions())
if err != nil {
log.Println("Can't send message to", chat.Title, ": ", err)
if res.ErrorCode == 403 {
feedChats.DeleteByID(ctx, chat.Id)
}
} else {
sent = true
}

View File

@ -29,9 +29,8 @@ var MainState = neco.State{
HandleFilter(docRequest, handleDocRequest).
HandleCallback(neco.CallbackPrefix("docs"), handleDocCallback)
triggers := neco.NewDispatcher().
HandleFilter(offtopTrigger, handleOfftop)
// triggers := neco.NewDispatcher()
return neco.RunEach(u, mainCommands, replies, docs, adminOnly, triggers)
return neco.RunEach(u, mainCommands, replies, docs, adminOnly)
},
}

View File

@ -16,7 +16,7 @@ type User struct {
Username string
Name string
ID int64
KarmaOffset int64
Karma int64
LastMessage time.Time
}
@ -56,7 +56,7 @@ type RatedUser struct {
tongo.Item `bson:",inline"`
Name string
ID int64
TotalKarma int64 `bson:"totalKarma"`
Karma int64 `bson:"karma"`
}
func (RatedUser) Coll() string { return "top10" }
@ -89,6 +89,15 @@ var karmaToIndex = mongo.IndexModel{
func (KarmaShot) Coll() string { return "karma" }
type KarmaMessage struct {
tongo.Item `bson:",inline"`
Template string `bson:"template"`
WordPlus string `bson:"word_plus"`
WordMinus string `bson:"word_minus"`
}
func (KarmaMessage) Coll() string { return "karma_messages" }
type Warn struct {
tongo.Item `bson:",inline"`
From int64
@ -134,3 +143,12 @@ type FeedChat struct {
}
func (FeedChat) Coll() string { return "feed_chats" }
type RemovableMessage struct {
tongo.Item `bson:",inline"`
ChatID int64
MessageID int
DeleteBy time.Time
}
func (RemovableMessage) Coll() string { return "removables" }

View File

@ -1,6 +1,7 @@
package main
import (
"log"
"strings"
"time"
@ -35,5 +36,7 @@ func StringHasSuffix(s string, subs ...string) bool {
func waitAndDelete(u *nechotron.Update, chatId int64, messageId int) {
time.Sleep(10 * time.Second)
u.Bot.DeleteMessage(chatId, messageId)
if _, err := u.Bot.DeleteMessage(chatId, messageId); err != nil {
log.Println("Can't wait-delete message: ", err)
}
}