diff --git a/bot.session b/bot.session deleted file mode 100644 index 3081256f..00000000 Binary files a/bot.session and /dev/null differ diff --git a/poetry.lock b/poetry.lock index d4b2ec3f..14e0db50 100644 --- a/poetry.lock +++ b/poetry.lock @@ -81,7 +81,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" [[package]] name = "docutils" -version = "0.17" +version = "0.16" description = "Docutils -- Python Documentation Utilities" category = "dev" optional = false @@ -223,7 +223,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "pytest" -version = "6.2.2" +version = "6.2.3" description = "pytest: simple powerful testing with Python" category = "dev" optional = false @@ -284,7 +284,7 @@ socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] [[package]] name = "royalnet" -version = "6.1.4" +version = "6.2.10" description = "A multipurpose bot framework" category = "main" optional = false @@ -317,7 +317,7 @@ python-versions = "*" [[package]] name = "sphinx" -version = "3.5.3" +version = "3.5.4" description = "Python documentation generator" category = "dev" optional = false @@ -327,7 +327,7 @@ python-versions = ">=3.5" alabaster = ">=0.7,<0.8" babel = ">=1.3" colorama = {version = ">=0.3.5", markers = "sys_platform == \"win32\""} -docutils = ">=0.12" +docutils = ">=0.12,<0.17" imagesize = "*" Jinja2 = ">=2.3" packaging = "*" @@ -348,13 +348,14 @@ test = ["pytest", "pytest-cov", "html5lib", "cython", "typed-ast"] [[package]] name = "sphinx-rtd-theme" -version = "0.5.1" +version = "0.5.2" description = "Read the Docs theme for Sphinx" category = "dev" optional = false python-versions = "*" [package.dependencies] +docutils = "<0.17" sphinx = "*" [package.extras] @@ -433,7 +434,7 @@ test = ["pytest"] [[package]] name = "sqlalchemy" -version = "1.4.5" +version = "1.4.7" description = "Database Abstraction Library" category = "main" optional = false @@ -509,7 +510,7 @@ brotli = ["brotlipy (>=0.6.0)"] [metadata] lock-version = "1.1" python-versions = "^3.8" -content-hash = "bcc3b7e2bfc0ff9a9b9c044e613a4f2dd99047173dd9b66e0e13c39d08e6a9d9" +content-hash = "f393839bc9bc0910f6ca4e3e1441fe69242dceb10ff23afd14ca97c80e6f1bff" [metadata.files] alabaster = [ @@ -549,8 +550,8 @@ colorama = [ {file = "colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b"}, ] docutils = [ - {file = "docutils-0.17-py2.py3-none-any.whl", hash = "sha256:a71042bb7207c03d5647f280427f14bfbd1a65c9eb84f4b341d85fafb6bb4bdf"}, - {file = "docutils-0.17.tar.gz", hash = "sha256:e2ffeea817964356ba4470efba7c2f42b6b0de0b04e66378507e3e2504bbff4c"}, + {file = "docutils-0.16-py2.py3-none-any.whl", hash = "sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af"}, + {file = "docutils-0.16.tar.gz", hash = "sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"}, ] greenlet = [ {file = "greenlet-1.0.0-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:1d1d4473ecb1c1d31ce8fd8d91e4da1b1f64d425c1dc965edc4ed2a63cfa67b2"}, @@ -730,8 +731,8 @@ pyparsing = [ {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, ] pytest = [ - {file = "pytest-6.2.2-py3-none-any.whl", hash = "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839"}, - {file = "pytest-6.2.2.tar.gz", hash = "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9"}, + {file = "pytest-6.2.3-py3-none-any.whl", hash = "sha256:6ad9c7bdf517a808242b998ac20063c41532a570d088d77eec1ee12b0b5574bc"}, + {file = "pytest-6.2.3.tar.gz", hash = "sha256:671238a46e4df0f3498d1c3270e5deb9b32d25134c99b7d75370a68cfbe9b634"}, ] pytest-asyncio = [ {file = "pytest-asyncio-0.14.0.tar.gz", hash = "sha256:9882c0c6b24429449f5f969a5158b528f39bde47dc32e85b9f0403965017e700"}, @@ -746,8 +747,8 @@ requests = [ {file = "requests-2.25.1.tar.gz", hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"}, ] royalnet = [ - {file = "royalnet-6.1.4-py3-none-any.whl", hash = "sha256:d9d3650b13dbfc5f8b93fd2dc66cdc742dec571d624b1a3294d4b066ae7766ef"}, - {file = "royalnet-6.1.4.tar.gz", hash = "sha256:8005c706c533046bebdcf9b8a1517da5c0e3f8cfaed9d33460cb15854f7d57b9"}, + {file = "royalnet-6.2.10-py3-none-any.whl", hash = "sha256:794d2f2c5d319a1649cf97355d7ad07c0ad36df4d96b4ad534eb1dc1c4a39caa"}, + {file = "royalnet-6.2.10.tar.gz", hash = "sha256:1a3f87b77fccce8df7571fcd0d8fbc5837b9f173a6d15c5e1e3e679a377b8ba5"}, ] rsa = [ {file = "rsa-4.7.2-py3-none-any.whl", hash = "sha256:78f9a9bf4e7be0c5ded4583326e7461e3a3c5aae24073648b4bdfa797d78c9d2"}, @@ -758,12 +759,12 @@ snowballstemmer = [ {file = "snowballstemmer-2.1.0.tar.gz", hash = "sha256:e997baa4f2e9139951b6f4c631bad912dfd3c792467e2f03d7239464af90e914"}, ] sphinx = [ - {file = "Sphinx-3.5.3-py3-none-any.whl", hash = "sha256:3f01732296465648da43dec8fb40dc451ba79eb3e2cc5c6d79005fd98197107d"}, - {file = "Sphinx-3.5.3.tar.gz", hash = "sha256:ce9c228456131bab09a3d7d10ae58474de562a6f79abb3dc811ae401cf8c1abc"}, + {file = "Sphinx-3.5.4-py3-none-any.whl", hash = "sha256:2320d4e994a191f4b4be27da514e46b3d6b420f2ff895d064f52415d342461e8"}, + {file = "Sphinx-3.5.4.tar.gz", hash = "sha256:19010b7b9fa0dc7756a6e105b2aacd3a80f798af3c25c273be64d7beeb482cb1"}, ] sphinx-rtd-theme = [ - {file = "sphinx_rtd_theme-0.5.1-py2.py3-none-any.whl", hash = "sha256:fa6bebd5ab9a73da8e102509a86f3fcc36dec04a0b52ea80e5a033b2aba00113"}, - {file = "sphinx_rtd_theme-0.5.1.tar.gz", hash = "sha256:eda689eda0c7301a80cf122dad28b1861e5605cbf455558f3775e1e8200e83a5"}, + {file = "sphinx_rtd_theme-0.5.2-py2.py3-none-any.whl", hash = "sha256:4a05bdbe8b1446d77a01e20a23ebc6777c74f43237035e76be89699308987d6f"}, + {file = "sphinx_rtd_theme-0.5.2.tar.gz", hash = "sha256:32bd3b5d13dc8186d7a42fc816a23d32e83a4827d7d9882948e7b837c232da5a"}, ] sphinxcontrib-applehelp = [ {file = "sphinxcontrib-applehelp-1.0.2.tar.gz", hash = "sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58"}, @@ -790,40 +791,40 @@ sphinxcontrib-serializinghtml = [ {file = "sphinxcontrib_serializinghtml-1.1.4-py2.py3-none-any.whl", hash = "sha256:f242a81d423f59617a8e5cf16f5d4d74e28ee9a66f9e5b637a18082991db5a9a"}, ] sqlalchemy = [ - {file = "SQLAlchemy-1.4.5-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:c3810ebcf1d42c532c8f5c3f442c705d94442a27a32f2df5344f0857306ab321"}, - {file = "SQLAlchemy-1.4.5-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:7481f9c2c832a3bf37c80bee44d91ac9938b815cc06f7e795b976e300914aab9"}, - {file = "SQLAlchemy-1.4.5-cp27-cp27m-win32.whl", hash = "sha256:94040a92b6676f9ffdab6c6b479b3554b927a635c90698c761960b266b04fc88"}, - {file = "SQLAlchemy-1.4.5-cp27-cp27m-win_amd64.whl", hash = "sha256:02b039e0e7e6de2f15ea2d2de3995e31a170e700ec0b37b4eded662171711d19"}, - {file = "SQLAlchemy-1.4.5-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:f16801795f1ffe9472360589a04301018c79e4582a85e68067275bb4f765e4e2"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:82f11b679df91275788be6734dd4a9dfa29bac67b85326992609f62b05bdab37"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:a08027ae84efc563f0f2f341dda572eadebeca38c0ae028a009988f27e9e6230"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:70a1387396ea5b3022539b560c287daf79403d8b4b365f89b56d660e625a4457"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:4f7ce3bfdab6520554af4a5b1df4513d45388624d015ba4d921daf48ce1d6503"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:08943201a1e3c6238e48f4d5d56c27ea1e1b39d3d9f36a9d81fc3cfb0e1b83bd"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-win32.whl", hash = "sha256:fbb0fda1c574975807aceb0e2332e0ecfe9e5656c191ed482c1a5eafe7a33823"}, - {file = "SQLAlchemy-1.4.5-cp36-cp36m-win_amd64.whl", hash = "sha256:8d6a9feb5efd2fdab25c6d5a0a5589fed9d789f5ec57ec12263fd0e60ce1dea6"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:c22bfac8d3b955cdb13f0fcd6343156bf56d925196cf7d9ab9ce9f61d3f1e11c"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:7c0c7bb49167ac738ca6ee6e7f94a9988a7e4e261d8da335341e8c8c8f3b2e9b"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:344b58b4b4193b72e8b768a51ef6eb5a4c948ce313a0f23e2ea081e71ce8ac0e"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:48540072f43b3c080159ec1f24a4b014c0ee83d3b73795399974aa358a8cf71b"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:81badd7d3e0e6aba70a5d1b50fabe8112e9835a6fdb0684054c3fe5378ce0d01"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-win32.whl", hash = "sha256:a103294583383660d9e06dbd82037dc8e94c184bdcb27b2be44ae4457dafc6b4"}, - {file = "SQLAlchemy-1.4.5-cp37-cp37m-win_amd64.whl", hash = "sha256:5361e25181b9872d6906c8c9be7dc05cb0a0951d71ee59ee5a71c1deb301b8a8"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:7f5087104c3c5af11ea59e49ae66c33ca98b14a47d3796ae97498fca53f84aef"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:11e7a86209f69273e75d2dd64b06c0c2660e39cd942fce2170515c404ed7358a"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:8301ecf3e819eb5dbc171e84654ff60872807775301a55fe35b0ab2ba3742031"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:44e11a06168782b6d485daef197783366ce7ab0d5eea0066c899ae06cef47bbc"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:6f8fdad2f335d2f3ca2f3ee3b01404f7abcf519b03de2c510f1f42d16e39ffb4"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-win32.whl", hash = "sha256:f62c57ceadedeb8e7b98b48ac4d684bf2b0f73b9d882fed3ca260d9aedf6403f"}, - {file = "SQLAlchemy-1.4.5-cp38-cp38-win_amd64.whl", hash = "sha256:301d0cd6ef1dc73b607748183da857e712d6f743de8d92b1e1f8facfb0ba2aa2"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:915d4fa08776c0252dc5a34fa15c6490f66f411ea1ac9492022f98875d6baf20"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:7de84feb31af3d8fdf819cac2042928d0b60d3cb16f49c4b2f48d88db46e79f6"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:45b091ccbf94374ed14abde17e9a04522b0493a17282eaaf4383efdd413f5243"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:4df07161897191ed8d4a0cfc92425c81296160e5c5f76c9256716d3085172883"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:ee4ddc904fb6414b5118af5b8d45e428aac2ccda01326b2ba2fe4354b0d8d1ae"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-win32.whl", hash = "sha256:2f11b5783933bff55291ca06496124347627d211ff2e509e846af1c35de0a3fb"}, - {file = "SQLAlchemy-1.4.5-cp39-cp39-win_amd64.whl", hash = "sha256:0ee0054d4a598d2920cae14bcbd33e200e02c5e3b47b902627f8cf5d4c9a2a4b"}, - {file = "SQLAlchemy-1.4.5.tar.gz", hash = "sha256:1294f05916c044631fd626a4866326bbfbd17f62bd37510d000afaef4b35bd74"}, + {file = "SQLAlchemy-1.4.7-cp27-cp27m-macosx_10_14_x86_64.whl", hash = "sha256:e9c2aaaa9738ba3334262734bd25d9b2d6ea446400f815bbdea17571b9e6d8fb"}, + {file = "SQLAlchemy-1.4.7-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:94fece3fdc777fbf37378513414bcf19ae89e1b598edf33d957a2898991d714f"}, + {file = "SQLAlchemy-1.4.7-cp27-cp27m-win32.whl", hash = "sha256:58075eab5e32daf51e637ac88c63057c3a5e84602cfeb30db4258838ef6f7a2b"}, + {file = "SQLAlchemy-1.4.7-cp27-cp27m-win_amd64.whl", hash = "sha256:8df743c79181ecc6aadaf10569d452ef3eda06764fe0adc4ea981a48c01e1ad5"}, + {file = "SQLAlchemy-1.4.7-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:bb69a2d93c1a98a8d4ca24a8012ade4b771087dddbe077ad4ef4911d7f17185d"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-macosx_10_14_x86_64.whl", hash = "sha256:d10117c9ce096bd6fb9a13c6fad274982f7889028e22a05719a6d219e2cf977e"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:abf18c62c4740d7199e443537066904789052d6d165cb279eb91bea35ea42ec4"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-manylinux2010_x86_64.whl", hash = "sha256:8672ff62c9d48f62aa17bb806a591cdfed801d139eecbcf9224bffb80f6fdc30"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:8ecabd4cead9a582e2ffa7a3918bc31155d5c24b1fd16ed617171f913c438da1"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-manylinux2014_x86_64.whl", hash = "sha256:e98934855337d76aa7726f444b0fa597a462271a95d01bc050644d88e1ee5aae"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-win32.whl", hash = "sha256:6adb07e199781457b75f4773e63577a2898f95141f030b956a2a186055f24e76"}, + {file = "SQLAlchemy-1.4.7-cp36-cp36m-win_amd64.whl", hash = "sha256:d81a68df4f3eee490b66ba990648d3c77cbf2475291ef92aa4e05ef541ecfd66"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-macosx_10_14_x86_64.whl", hash = "sha256:ef6d98d5b51eb826516499429e059872b61e272cb44630ca8de87650242d07d8"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:d5ef5619d421f8a86af874f867d17d823cd970ad0f2ae7c30723beb16922b4d6"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-manylinux2010_x86_64.whl", hash = "sha256:c74310f13e5a113ef658345e2cedf9aa1fcb8b9a588e07d54c083c7fc71edf42"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:069fcda89c7d168382f674b5b566643f1420e4e7704c00cced2579675deb4eed"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-manylinux2014_x86_64.whl", hash = "sha256:673cb375deb17e1561340710f428b33c27a11980d991a2ac88d7bf1c623faa0b"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-win32.whl", hash = "sha256:aea57c7a5a4135abc10f81ce433b23325cbb9648a5dcb0ac1af1cdd413f7d0cb"}, + {file = "SQLAlchemy-1.4.7-cp37-cp37m-win_amd64.whl", hash = "sha256:6913ea108e7583f2d7ba4bc9cf4f2b1e0cdacf7e66e4cdc04192f870e64306ff"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-macosx_10_14_x86_64.whl", hash = "sha256:72152b64508dd807ba2a26d9dfc4da450d0ba1808c9f96ddbc397c435735fac3"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:9de4c84ea180c07f1d4010db2cfdbf9fe67bf7caafcfb1053644c8c03bfa3fd0"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-manylinux2010_x86_64.whl", hash = "sha256:89860d594cb3256718d74ff7406a405a890eac71bcc044b3ba6868850d934a48"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:5d84442d85491dc473bf99f4d90ad45dd2e5539743f4d1216b15ba26575ba572"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-manylinux2014_x86_64.whl", hash = "sha256:fdd1e4ed5d526aa4c7a01ed2157d01f0234eaecdb04b1c3b5084d0902986be9f"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-win32.whl", hash = "sha256:3a022a7985a49cacf21e2a73bab083e4852943466d250d932554650d705fcc62"}, + {file = "SQLAlchemy-1.4.7-cp38-cp38-win_amd64.whl", hash = "sha256:a7f450cbab9670949e7d9f0eac1dd93eaaffce319608bf4b863f0b751decef42"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-macosx_10_14_x86_64.whl", hash = "sha256:2bfadb3279f51252565baed9aa071c1bef875fcde60bf4a172136289ac208804"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:1d1172a9e5ead90d9299ccad8c5eecf40372a3721ff82fc4b4ee42835baf4659"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-manylinux2010_x86_64.whl", hash = "sha256:bea07faab746743c8d82650b51129ff2705d53a0094161cfa6145e7ce77b9644"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:a3a40d2a0cb2ca2886f8f2fe768e83aeca489a162c8233974b9b2e429827ed85"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-manylinux2014_x86_64.whl", hash = "sha256:50b1cb7c9f6f0bbc68c06453d66d4a34ca75ba60bce61d49bf007edfd2621d0a"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-win32.whl", hash = "sha256:d26d8a3865c9f33d7b3b356a577c7f26c499a9f080ae33e4282a65a8a2170cef"}, + {file = "SQLAlchemy-1.4.7-cp39-cp39-win_amd64.whl", hash = "sha256:606ac6a7640cc642fd53c5e693c560ad9fc21ef97aa7e799eb96b6d7f28ad723"}, + {file = "SQLAlchemy-1.4.7.tar.gz", hash = "sha256:84115f97d88c8ccf26db81b7997c5f5de9ae360e0785ef859d0987794495f0a9"}, ] telethon = [ {file = "Telethon-1.21.1-py3-none-any.whl", hash = "sha256:df643fc988708ad16d16de834ffa12ad4bfa3f956473d835c8158e2283b885ea"}, diff --git a/pyproject.toml b/pyproject.toml index fc147431..5396d289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "royalnet-telethon" -version = "0.2.0" +version = "0.3.4" description = "A Telethon-based frontend for the royalnet.engineer module." authors = ["Stefano Pigozzi "] license = "AGPL-3.0-or-later" @@ -14,12 +14,11 @@ classifiers = [ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Operating System :: OS Independent", "Programming Language :: Python :: 3.8", - "Topic :: Terminals", ] [tool.poetry.dependencies] python = "^3.8" -royalnet = "^6.1.2" +royalnet = "~6.2.10" Telethon = "^1.21.1" click = "^7.1.2" diff --git a/royalnet_telethon/__main__.py b/royalnet_telethon/__main__.py deleted file mode 100644 index 9dcbf23f..00000000 --- a/royalnet_telethon/__main__.py +++ /dev/null @@ -1,67 +0,0 @@ -# Special imports -from __future__ import annotations -import royalnet.royaltyping as t - -# External imports -import logging -import importlib -import click -import asyncio -import royalnet.engineer as engi - -# Internal imports -from .pda import TelethonPDA - -# Special global objects -log = logging.getLogger(__name__) - - -# Code -@click.command() -@click.option("-p", "--pack", "packs", multiple=True) -@click.option("-i", "--api-id", "api_id", required=True, type=int) -@click.option("-h", "--api-hash", "api_hash", required=True) -@click.option("-t", "--token", "token", required=True) -@click.option("-u", "--username", "username", required=True) -def main(packs: t.List[str], token: str, api_id: int, api_hash: str, username: str): - log.debug("Creating PDA...") - pda = TelethonPDA(tg_api_id=api_id, tg_api_hash=api_hash, bot_username=username) - - for pack in packs: - log.debug(f"Importing module: {pack!r}") - try: - pack = importlib.import_module(pack) - except ImportError as e: - log.error(f"Skipping {pack!r}: {e!r}") - continue - - for attribute in dir(pack): - log.debug(f"Getting attribute: {attribute!r}") - value = pack.__getattribute__(attribute) - log.debug(f"Attribute is: {value!r}") - - if isinstance(value, engi.PartialCommand): - log.debug(f"Attribute is a PartialCommand, registering it as: {value.f.__name__!r}") - pda.register_partial(part=value, names=[value.f.__name__]) - - elif isinstance(value, engi.Conversation): - log.debug(f"Attribute is a Conversation, registering it...") - pda.register_conversation(conv=value) - - log.debug("Getting event loop...") - loop = asyncio.get_event_loop() - log.debug(f"Event loop is: {loop!r}") - - log.debug("Running the PDA until interrupted...") - try: - loop.run_until_complete(pda.run(bot_token=token)) - except KeyboardInterrupt: - log.debug("Got an interrupt, shutting down...") - exit(0) - - log.fatal("PDA stopped unexpectedly, shutting down...") - exit(1) - - -if __name__ == "__main__": - main() diff --git a/royalnet_telethon/pda.py b/royalnet_telethon/pda.py index 56786bae..3d361acc 100644 --- a/royalnet_telethon/pda.py +++ b/royalnet_telethon/pda.py @@ -6,7 +6,6 @@ from __future__ import annotations import royalnet.royaltyping as t import logging -import asyncio import royalnet.engineer as engi import telethon as tt import telethon.tl.custom as tlc @@ -18,34 +17,35 @@ log = logging.getLogger(__name__) class TelethonPDAMode(enum.Enum): + """ + .. todo:: Document this. + """ + GLOBAL = enum.auto() CHAT = enum.auto() USER = enum.auto() CHAT_USER = enum.auto() -class TelethonPDA: +class TelethonPDAImplementation(engi.ConversationListImplementation): """ - A PDA which handles :mod:`royalnet` input and output using a Telegram bot as a source. + .. todo:: Document this. """ - def __init__(self, - tg_api_id: int, - tg_api_hash: str, - bot_username: str, - mode: TelethonPDAMode = TelethonPDAMode.CHAT_USER, - ): - """ - Create a new :class:`.TelethonPDA` . + def _partialcommand_pattern(self, partial) -> str: + if partial.syntax: + return rf"^/{{name}}(?:@{self.bot_username})?\s+{{syntax}}$" + else: + return rf"^/{{name}}(?:@{self.bot_username})?$" - Get API properties `here `_. + @property + def namespace(self): + return "telethon" - :param tg_api_id: The Telegram ``api_id``. - :param tg_api_hash: The Telegram ``api_hash``. - :param mode: The mode to use for mapping dispensers. - """ + def __init__(self, name: str, tg_api_id: int, tg_api_hash: str, bot_username: str, bot_token: str, + mode: TelethonPDAMode = TelethonPDAMode.CHAT_USER, extensions = None): - log.debug(f"Creating new TelethonPDA...") + super().__init__(name=name, extensions=extensions) self.dispensers: dict[t.Any, engi.Dispenser] = {} """ @@ -58,24 +58,43 @@ class TelethonPDA: :class:`~royalnet.engineer.dispenser.Dispenser`. """ - self.client: tt.TelegramClient = tt.TelegramClient("bot", api_id=tg_api_id, api_hash=tg_api_hash) - """ - The :mod:`telethon` Telegram _client that this PDA will use to interface with Telegram. - """ - - self._register_events() - self.mode: TelethonPDAMode = mode """ The mode to use for mapping dispensers. """ - self.bot_username: str = bot_username + self.tg_api_id: int = tg_api_id + """ + .. todo:: Document this. + """ - def _register_events(self): - self.client.add_event_handler(callback=self._message_new, event=tt.events.NewMessage()) - self.client.add_event_handler(callback=self._message_edit, event=tt.events.MessageEdited()) - self.client.add_event_handler(callback=self._message_delete, event=tt.events.MessageDeleted()) + self.tg_api_hash: str = tg_api_hash + """ + .. todo:: Document this. + """ + + self.bot_username: str = bot_username + """ + .. todo:: Document this. + """ + + self.bot_token: str = bot_token + """ + .. todo:: Document this. + """ + + def _register_events(self, client): + """ + .. todo:: Document this. + """ + + self.log.info("Registering Telethon events...") + self.log.debug("Registering NewMessage event...") + client.add_event_handler(callback=self._message_new, event=tt.events.NewMessage()) + self.log.debug("Registering MessageEdited event...") + client.add_event_handler(callback=self._message_edit, event=tt.events.MessageEdited()) + self.log.debug("Registering MessageDeleted event...") + client.add_event_handler(callback=self._message_delete, event=tt.events.MessageDeleted()) # self._client.add_event_handler(callback=self._message_read, _event=tt.events.MessageRead()) # self._client.add_event_handler(callback=self._chat_action, _event=tt.events.ChatAction()) # self._client.add_event_handler(callback=self._user_update, _event=tt.events.UserUpdate()) @@ -84,6 +103,10 @@ class TelethonPDA: # self._client.add_event_handler(callback=self._album, _event=tt.events.Album()) def _determine_key(self, event: tlc.message.Message): + """ + .. todo:: Document this. + """ + if self.mode == TelethonPDAMode.GLOBAL: return None elif self.mode == TelethonPDAMode.USER: @@ -102,101 +125,50 @@ class TelethonPDA: raise TypeError("Invalid mode") async def _message_new(self, event: tlc.message.Message): + """ + .. todo:: Document this. + """ + await self.put_projectile( key=self._determine_key(event), - proj=TelegramMessageReceived(event=event), + projectile=TelegramMessageReceived(event=event), ) async def _message_edit(self, event: tlc.message.Message): + """ + .. todo:: Document this. + """ + await self.put_projectile( key=self._determine_key(event), - proj=TelegramMessageEdited(event=event), + projectile=TelegramMessageEdited(event=event), ) async def _message_delete(self, event: tlc.message.Message): + """ + .. todo:: Document this. + """ + await self.put_projectile( key=self._determine_key(event), - proj=TelegramMessageDeleted(event=event), + projectile=TelegramMessageDeleted(event=event), ) - async def run(self, bot_token: str) -> t.NoReturn: - """ - Run the main loop of the :class:`.ConsolePDA` for ``cycles`` cycles, or unlimited cycles if the parameter is - :data:`True`. - """ - # Login to the Telegram API - self.client: tt.TelegramClient = await self.client.start(bot_token=bot_token) - await self.client.connect() - await self.client.get_me() - await self.client.catch_up() - await self.client.run_until_disconnected() + async def run(self) -> t.NoReturn: + client = tt.TelegramClient( + "bot", + api_id=self.tg_api_id, + api_hash=self.tg_api_hash + ) - def register_conversation(self, conv: engi.Conversation) -> None: - """ - Register a new conversation in the PDA. - - :param conv: The conversation to register. - """ - log.info(f"Registering conversation: {conv!r}") - self.conversations.append(conv) - - def unregister_conversation(self, conv: engi.Conversation) -> None: - """ - Unregister a conversation from the PDA. - - :param conv: The conversation to unregister. - """ - log.info(f"Unregistering conversation: {conv!r}") - self.conversations.remove(conv) - - def register_partial(self, part: engi.PartialCommand, names: t.List[str]) -> engi.Command: - """ - Register a new :class:`~royalnet.engineer.command.PartialCommand` in the PDA, converting it to a - :class:`royalnet.engineer.Command` in the process. - - :param part: The :class:`~royalnet.engineer.command.PartialCommand` to register. - :param names: The :attr:`~royalnet.engineer.command.Command.names` to register the command with. - :return: The resulting :class:`~royalnet.engineer.command.Command`. - """ - log.debug(f"Completing partial: {part!r}") - if part.syntax: - command = part.complete(pattern=rf"^/{{name}}(?:@{self.bot_username})?\s+{{syntax}}$", names=names) - else: - command = part.complete(pattern=rf"^/{{name}}(?:@{self.bot_username})?$", names=names) - self.register_conversation(command) - return command - - async def put_projectile(self, key: t.Any, proj: engi.Projectile) -> None: - """ - Insert a new projectile into the dispenser. - - :param key: The key of the dispenser to interact with. - :param proj: The projectile to put in the dispenser. - """ - if key not in self.dispensers: - log.debug(f"Dispenser not found, creating one...") - self.dispensers[key] = engi.Dispenser() - - dispenser = self.dispensers[key] - - log.debug("Getting running loop...") - loop = asyncio.get_running_loop() - - for conversation in self.conversations: - log.debug(f"Creating run task for: {conversation!r}") - loop.create_task(dispenser.run(conversation, _pda=self), name=f"{repr(conversation)}") - - log.debug("Running a _event loop cycle...") - await asyncio.sleep(0) - - log.debug(f"Putting projectile {proj!r} in dispenser {dispenser!r}...") - await dispenser.put(proj) - - log.debug("Awaiting another _event loop cycle...") - await asyncio.sleep(0) + await client.start(bot_token=self.bot_token) + try: + self._register_events(client) + await client.run_until_disconnected() + finally: + await client.disconnect() -# Objects exported by this module __all__ = ( - "TelethonPDA", + "TelethonPDAImplementation", )