diff --git a/.gitignore b/.gitignore index 43099ae1b..a5ad527dd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,135 @@ tg_bot/config.py .pydevproject .directory .vscode +*.env* + +# Created by https://www.gitignore.io/api/python +# Edit at https://www.gitignore.io/?templates=python + +### Python ### +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# End of https://www.gitignore.io/api/python diff --git a/Pipfile b/Pipfile new file mode 100644 index 000000000..2a0ab1100 --- /dev/null +++ b/Pipfile @@ -0,0 +1,18 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +future = "*" +emoji = "*" +requests = "*" +python-telegram-bot = ">=11.1.0" +psycopg2-binary = "*" +feedparser = "*" +SQLAlchemy = "*" + +[requires] +python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 000000000..f87b192bf --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,204 @@ +{ + "_meta": { + "hash": { + "sha256": "e4286591944171474f32d78423089327dd2b35e56fa624cf565a5c8d41fed33d" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "asn1crypto": { + "hashes": [ + "sha256:2f1adbb7546ed199e3c90ef23ec95c5cf3585bac7d11fb7eb562a3fe89c64e87", + "sha256:9d5c20441baf0cb60a4ac34cc447c6c189024b6b4c6cd7877034f4965c464e49" + ], + "version": "==0.24.0" + }, + "certifi": { + "hashes": [ + "sha256:046832c04d4e752f37383b628bc601a7ea7211496b4638f6514d0e5b9acc4939", + "sha256:945e3ba63a0b9f577b1395204e13c3a231f9bc0223888be653286534e5873695" + ], + "version": "==2019.6.16" + }, + "cffi": { + "hashes": [ + "sha256:041c81822e9f84b1d9c401182e174996f0bae9991f33725d059b771744290774", + "sha256:046ef9a22f5d3eed06334d01b1e836977eeef500d9b78e9ef693f9380ad0b83d", + "sha256:066bc4c7895c91812eff46f4b1c285220947d4aa46fa0a2651ff85f2afae9c90", + "sha256:066c7ff148ae33040c01058662d6752fd73fbc8e64787229ea8498c7d7f4041b", + "sha256:2444d0c61f03dcd26dbf7600cf64354376ee579acad77aef459e34efcb438c63", + "sha256:300832850b8f7967e278870c5d51e3819b9aad8f0a2c8dbe39ab11f119237f45", + "sha256:34c77afe85b6b9e967bd8154e3855e847b70ca42043db6ad17f26899a3df1b25", + "sha256:46de5fa00f7ac09f020729148ff632819649b3e05a007d286242c4882f7b1dc3", + "sha256:4aa8ee7ba27c472d429b980c51e714a24f47ca296d53f4d7868075b175866f4b", + "sha256:4d0004eb4351e35ed950c14c11e734182591465a33e960a4ab5e8d4f04d72647", + "sha256:4e3d3f31a1e202b0f5a35ba3bc4eb41e2fc2b11c1eff38b362de710bcffb5016", + "sha256:50bec6d35e6b1aaeb17f7c4e2b9374ebf95a8975d57863546fa83e8d31bdb8c4", + "sha256:55cad9a6df1e2a1d62063f79d0881a414a906a6962bc160ac968cc03ed3efcfb", + "sha256:5662ad4e4e84f1eaa8efce5da695c5d2e229c563f9d5ce5b0113f71321bcf753", + "sha256:59b4dc008f98fc6ee2bb4fd7fc786a8d70000d058c2bbe2698275bc53a8d3fa7", + "sha256:73e1ffefe05e4ccd7bcea61af76f36077b914f92b76f95ccf00b0c1b9186f3f9", + "sha256:a1f0fd46eba2d71ce1589f7e50a9e2ffaeb739fb2c11e8192aa2b45d5f6cc41f", + "sha256:a2e85dc204556657661051ff4bab75a84e968669765c8a2cd425918699c3d0e8", + "sha256:a5457d47dfff24882a21492e5815f891c0ca35fefae8aa742c6c263dac16ef1f", + "sha256:a8dccd61d52a8dae4a825cdbb7735da530179fea472903eb871a5513b5abbfdc", + "sha256:ae61af521ed676cf16ae94f30fe202781a38d7178b6b4ab622e4eec8cefaff42", + "sha256:b012a5edb48288f77a63dba0840c92d0504aa215612da4541b7b42d849bc83a3", + "sha256:d2c5cfa536227f57f97c92ac30c8109688ace8fa4ac086d19d0af47d134e2909", + "sha256:d42b5796e20aacc9d15e66befb7a345454eef794fdb0737d1af593447c6c8f45", + "sha256:dee54f5d30d775f525894d67b1495625dd9322945e7fee00731952e0368ff42d", + "sha256:e070535507bd6aa07124258171be2ee8dfc19119c28ca94c9dfb7efd23564512", + "sha256:e1ff2748c84d97b065cc95429814cdba39bcbd77c9c85c89344b317dc0d9cbff", + "sha256:ed851c75d1e0e043cbf5ca9a8e1b13c4c90f3fbd863dacb01c0808e2b5204201" + ], + "version": "==1.12.3" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "cryptography": { + "hashes": [ + "sha256:24b61e5fcb506424d3ec4e18bca995833839bf13c59fc43e530e488f28d46b8c", + "sha256:25dd1581a183e9e7a806fe0543f485103232f940fcfc301db65e630512cce643", + "sha256:3452bba7c21c69f2df772762be0066c7ed5dc65df494a1d53a58b683a83e1216", + "sha256:41a0be220dd1ed9e998f5891948306eb8c812b512dc398e5a01846d855050799", + "sha256:5751d8a11b956fbfa314f6553d186b94aa70fdb03d8a4d4f1c82dcacf0cbe28a", + "sha256:5f61c7d749048fa6e3322258b4263463bfccefecb0dd731b6561cb617a1d9bb9", + "sha256:72e24c521fa2106f19623a3851e9f89ddfdeb9ac63871c7643790f872a305dfc", + "sha256:7b97ae6ef5cba2e3bb14256625423413d5ce8d1abb91d4f29b6d1a081da765f8", + "sha256:961e886d8a3590fd2c723cf07be14e2a91cf53c25f02435c04d39e90780e3b53", + "sha256:96d8473848e984184b6728e2c9d391482008646276c3ff084a1bd89e15ff53a1", + "sha256:ae536da50c7ad1e002c3eee101871d93abdc90d9c5f651818450a0d3af718609", + "sha256:b0db0cecf396033abb4a93c95d1602f268b3a68bb0a9cc06a7cff587bb9a7292", + "sha256:cfee9164954c186b191b91d4193989ca994703b2fff406f71cf454a2d3c7327e", + "sha256:e6347742ac8f35ded4a46ff835c60e68c22a536a8ae5c4422966d06946b6d4c6", + "sha256:f27d93f0139a3c056172ebb5d4f9056e770fdf0206c2f422ff2ebbad142e09ed", + "sha256:f57b76e46a58b63d1c6375017f4564a28f19a5ca912691fd2e4261b3414b618d" + ], + "version": "==2.7" + }, + "emoji": { + "hashes": [ + "sha256:9ae01495fc3fcc04e9136ca1af8cae58726ec5dfaaa92f61f0732cbae9a12fa9", + "sha256:cecf8ed7cc535c999dc96e3fe7e7aacd176deb9ef62b3ef022c535e155084c44" + ], + "index": "pypi", + "version": "==0.5.2" + }, + "feedparser": { + "hashes": [ + "sha256:bd030652c2d08532c034c27fcd7c85868e7fa3cb2b17f230a44a6bbc92519bf9", + "sha256:cd2485472e41471632ed3029d44033ee420ad0b57111db95c240c9160a85831c", + "sha256:ce875495c90ebd74b179855449040003a1beb40cd13d5f037a0654251e260b02" + ], + "index": "pypi", + "version": "==5.2.1" + }, + "future": { + "hashes": [ + "sha256:67045236dcfd6816dc439556d009594abf643e5eb48992e36beac09c2ca659b8" + ], + "index": "pypi", + "version": "==0.17.1" + }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "psycopg2-binary": { + "hashes": [ + "sha256:080c72714784989474f97be9ab0ddf7b2ad2984527e77f2909fcd04d4df53809", + "sha256:110457be80b63ff4915febb06faa7be002b93a76e5ba19bf3f27636a2ef58598", + "sha256:171352a03b22fc099f15103959b52ee77d9a27e028895d7e5fde127aa8e3bac5", + "sha256:19d013e7b0817087517a4b3cab39c084d78898369e5c46258aab7be4f233d6a1", + "sha256:249b6b21ae4eb0f7b8423b330aa80fab5f821b9ffc3f7561a5e2fd6bb142cf5d", + "sha256:2ac0731d2d84b05c7bb39e85b7e123c3a0acd4cda631d8d542802c88deb9e87e", + "sha256:2b6d561193f0dc3f50acfb22dd52ea8c8dfbc64bcafe3938b5f209cc17cb6f00", + "sha256:2bd23e242e954214944481124755cbefe7c2cf563b1a54cd8d196d502f2578bf", + "sha256:3e1239242ca60b3725e65ab2f13765fc199b03af9eaf1b5572f0e97bdcee5b43", + "sha256:3eb70bb697abbe86b1d2b1316370c02ba320bfd1e9e35cf3b9566a855ea8e4e5", + "sha256:51a2fc7e94b98bd1bb5d4570936f24fc2b0541b63eccadf8fdea266db8ad2f70", + "sha256:52f1bdafdc764b7447e393ed39bb263eccb12bfda25a4ac06d82e3a9056251f6", + "sha256:5b3581319a3951f1e866f4f6c5e42023db0fae0284273b82e97dfd32c51985cd", + "sha256:63c1b66e3b2a3a336288e4bcec499e0dc310cd1dceaed1c46fa7419764c68877", + "sha256:8123a99f24ecee469e5c1339427bcdb2a33920a18bb5c0d58b7c13f3b0298ba3", + "sha256:85e699fcabe7f817c0f0a412d4e7c6627e00c412b418da7666ff353f38e30f67", + "sha256:8dbff4557bbef963697583366400822387cccf794ccb001f1f2307ed21854c68", + "sha256:908d21d08d6b81f1b7e056bbf40b2f77f8c499ab29e64ec5113052819ef1c89b", + "sha256:af39d0237b17d0a5a5f638e9dffb34013ce2b1d41441fd30283e42b22d16858a", + "sha256:af51bb9f055a3f4af0187149a8f60c9d516cf7d5565b3dac53358796a8fb2a5b", + "sha256:b2ecac57eb49e461e86c092761e6b8e1fd9654dbaaddf71a076dcc869f7014e2", + "sha256:cd37cc170678a4609becb26b53a2bc1edea65177be70c48dd7b39a1149cabd6e", + "sha256:d17e3054b17e1a6cb8c1140f76310f6ede811e75b7a9d461922d2c72973f583e", + "sha256:d305313c5a9695f40c46294d4315ed3a07c7d2b55e48a9010dad7db7a66c8b7f", + "sha256:dd0ef0eb1f7dd18a3f4187226e226a7284bda6af5671937a221766e6ef1ee88f", + "sha256:e1adff53b56db9905db48a972fb89370ad5736e0450b96f91bcf99cadd96cfd7", + "sha256:f0d43828003c82dbc9269de87aa449e9896077a71954fbbb10a614c017e65737", + "sha256:f78e8b487de4d92640105c1389e5b90be3496b1d75c90a666edd8737cc2dbab7" + ], + "index": "pypi", + "version": "==2.8.3" + }, + "pycparser": { + "hashes": [ + "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" + ], + "version": "==2.19" + }, + "python-telegram-bot": { + "hashes": [ + "sha256:78695b1f6e147e9b360ccfb1ac92b542cab27870ccaf04065a88ee601ffa58b6", + "sha256:cca4e32ebb8da7fdf35ab2fa2b3edd441211364819c5592fc253acdb7561ea5b" + ], + "index": "pypi", + "version": "==11.1.0" + }, + "requests": { + "hashes": [ + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" + ], + "index": "pypi", + "version": "==2.22.0" + }, + "six": { + "hashes": [ + "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", + "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" + ], + "version": "==1.12.0" + }, + "sqlalchemy": { + "hashes": [ + "sha256:c30925d60af95443458ebd7525daf791f55762b106049ae71e18f8dd58084c2f" + ], + "index": "pypi", + "version": "==1.3.5" + }, + "urllib3": { + "hashes": [ + "sha256:b246607a25ac80bedac05c6f282e3cdaf3afb65420fd024ac94435cabe6e18d1", + "sha256:dbe59173209418ae49d485b87d1681aefa36252ee85884c31346debd19463232" + ], + "version": "==1.25.3" + } + }, + "develop": {} +} diff --git a/README.md b/README.md index b5c622498..760a6c357 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # tgbot + A modular telegram Python bot running on python3 with an sqlalchemy database. Originally a simple group management bot with multiple admin features, it has evolved into becoming a basis for modular @@ -10,17 +11,15 @@ For questions regarding creating your own bot, please head to [this chat](https: group of volunteers to help. We'll also help when a database schema changes, and some table column needs to be modified/added (this info can also be found in the commit messages) - Join the [news channel](https://t.me/MarieNews) if you just want to stay in the loop about new features or announcements. Marie and I can also be found moderating the [marie support group](https://t.me/MarieSupport) aimed at providing help -setting up Marie in your chats (*not* for bot clones). +setting up Marie in your chats (_not_ for bot clones). Feel free to join to report bugs, and stay in the loop on the status of the bot development. Note to maintainers that all schema changes will be found in the commit messages, and its their responsibility to read any new commits. - ## IMPORTANT NOTICE: This project is no longer under active maintenance. Occasional bug fixes may be released, but no new features are scheduled to be added. @@ -33,8 +32,8 @@ Once you've setup your database and your configuration (see below) is complete, `python3 -m tg_bot` - ## Setting up the bot (Read this before trying to use!): + Please make sure to use python3.6, as I cannot guarantee everything will work as expected on older python versions! This is because markdown parsing is done by iterating through a dict, which are ordered by default in 3.6. @@ -43,14 +42,15 @@ This is because markdown parsing is done by iterating through a dict, which are There are two possible ways of configuring your bot: a config.py file, or ENV variables. The prefered version is to use a `config.py` file, as it makes it easier to see all your settings grouped together. -This file should be placed in your `tg_bot` folder, alongside the `__main__.py` file . -This is where your bot token will be loaded from, as well as your database URI (if you're using a database), and most of +This file should be placed in your `tg_bot` folder, alongside the `__main__.py` file . +This is where your bot token will be loaded from, as well as your database URI (if you're using a database), and most of your other settings. -It is recommended to import sample_config and extend the Config class, as this will ensure your config contains all +It is recommended to import sample_config and extend the Config class, as this will ensure your config contains all defaults set in the sample_config, hence making it easier to upgrade. An example `config.py` file could be: + ``` from tg_bot.sample_config import Config @@ -69,34 +69,35 @@ class Development(Config): If you can't have a config.py file (EG on heroku), it is also possible to use environment variables. The following env variables are supported: - - `ENV`: Setting this to ANYTHING will enable env variables - - - `TOKEN`: Your bot token, as a string. - - `OWNER_ID`: An integer of consisting of your owner ID - - `OWNER_USERNAME`: Your username - - - `DATABASE_URL`: Your database URL - - `MESSAGE_DUMP`: optional: a chat where your replied saved messages are stored, to stop people deleting their old - - `LOAD`: Space separated list of modules you would like to load - - `NO_LOAD`: Space separated list of modules you would like NOT to load - - `WEBHOOK`: Setting this to ANYTHING will enable webhooks when in env mode - messages - - `URL`: The URL your webhook should connect to (only needed for webhook mode) - - - `SUDO_USERS`: A space separated list of user_ids which should be considered sudo users - - `SUPPORT_USERS`: A space separated list of user_ids which should be considered support users (can gban/ungban, - nothing else) - - `WHITELIST_USERS`: A space separated list of user_ids which should be considered whitelisted - they can't be banned. - - `DONATION_LINK`: Optional: link where you would like to receive donations. - - `CERT_PATH`: Path to your webhook certificate - - `PORT`: Port to use for your webhooks - - `DEL_CMDS`: Whether to delete commands from users which don't have rights to use that command - - `STRICT_GBAN`: Enforce gbans across new groups as well as old groups. When a gbanned user talks, he will be banned. - - `WORKERS`: Number of threads to use. 8 is the recommended (and default) amount, but your experience may vary. - __Note__ that going crazy with more threads wont necessarily speed up your bot, given the large amount of sql data - accesses, and the way python asynchronous calls work. - - `BAN_STICKER`: Which sticker to use when banning people. - - `ALLOW_EXCL`: Whether to allow using exclamation marks ! for commands as well as /. + +- `ENV`: Setting this to ANYTHING will enable env variables + +- `TOKEN`: Your bot token, as a string. +- `OWNER_ID`: An integer of consisting of your owner ID +- `OWNER_USERNAME`: Your username + +- `DATABASE_URL`: Your database URL +- `MESSAGE_DUMP`: optional: a chat where your replied saved messages are stored, to stop people deleting their old +- `LOAD`: Space separated list of modules you would like to load +- `NO_LOAD`: Space separated list of modules you would like NOT to load +- `WEBHOOK`: Setting this to ANYTHING will enable webhooks when in env mode + messages +- `URL`: The URL your webhook should connect to (only needed for webhook mode) + +- `SUDO_USERS`: A space separated list of user_ids which should be considered sudo users +- `SUPPORT_USERS`: A space separated list of user_ids which should be considered support users (can gban/ungban, + nothing else) +- `WHITELIST_USERS`: A space separated list of user_ids which should be considered whitelisted - they can't be banned. +- `DONATION_LINK`: Optional: link where you would like to receive donations. +- `CERT_PATH`: Path to your webhook certificate +- `PORT`: Port to use for your webhooks +- `DEL_CMDS`: Whether to delete commands from users which don't have rights to use that command +- `STRICT_GBAN`: Enforce gbans across new groups as well as old groups. When a gbanned user talks, he will be banned. +- `WORKERS`: Number of threads to use. 8 is the recommended (and default) amount, but your experience may vary. + **Note** that going crazy with more threads wont necessarily speed up your bot, given the large amount of sql data + accesses, and the way python asynchronous calls work. +- `BAN_STICKER`: Which sticker to use when banning people. +- `ALLOW_EXCL`: Whether to allow using exclamation marks ! for commands as well as /. ### Python dependencies @@ -148,6 +149,7 @@ Replace sqldbtype with whichever db youre using (eg postgres, mysql, sqllite, et repeat for your username, password, hostname (localhost?), port (5432?), and db name. ## Modules + ### Setting load order. The module load order can be changed via the `LOAD` and `NO_LOAD` configuration settings. @@ -178,8 +180,20 @@ commands will allow the bot to load it and add the documentation for your module to the `/help` command. Setting the `__mod_name__` variable will also allow you to use a nicer, user friendly name for a module. -The `__migrate__()` function is used for migrating chats - when a chat is upgraded to a supergroup, the ID changes, so +The `__migrate__()` function is used for migrating chats - when a chat is upgraded to a supergroup, the ID changes, so it is necessary to migrate it in the db. -The `__stats__()` function is for retrieving module statistics, eg number of users, number of chats. This is accessed +The `__stats__()` function is for retrieving module statistics, eg number of users, number of chats. This is accessed through the `/stats` command, which is only available to the bot owner. + +### Running dev with docker + +#### Requirements + +- docker +- docker-compose + +#### Up & Running + +- Create .env file by using docker/dev/config.sample as template and save it into docker/dev/ +- Be sure to be at project root directory and run `docker-compose -f docker/dev/docker-compose.yml up -d` diff --git a/config.sample b/config.sample new file mode 100644 index 000000000..0604e4337 --- /dev/null +++ b/config.sample @@ -0,0 +1,9 @@ +ENV=boolean +TOKEN=your-token +OWNER_ID=your-owner-id +OWNER_USERNAME=your-owner-username +DATABASE_URL=postgresql://your-user:your-pwd@db:5432/tgbot +SUDO_USERS=your-sudo-users-id +POSTGRES_PASSWORD=your-pg-password +POSTGRES_DB=tgbot +POSTGRES_USER=your-pg-user diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile new file mode 100644 index 000000000..6f0ff01cf --- /dev/null +++ b/docker/dev/Dockerfile @@ -0,0 +1,12 @@ +FROM python:3.6-stretch + +ENV PYTHONDONTWRITEBYTECODE 1 +ENV PYTHONUNBUFFERED 1 + +WORKDIR /tgbot + +RUN pip install pipenv +COPY requirements.txt Pipfile Pipfile.lock /tgbot/ +RUN pipenv install -r requirements.txt + +COPY . /tgbot/ diff --git a/docker/dev/Pipfile b/docker/dev/Pipfile new file mode 100644 index 000000000..9534830b5 --- /dev/null +++ b/docker/dev/Pipfile @@ -0,0 +1,11 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] + +[requires] +python_version = "3.6" diff --git a/docker/dev/Pipfile.lock b/docker/dev/Pipfile.lock new file mode 100644 index 000000000..419c7abf2 --- /dev/null +++ b/docker/dev/Pipfile.lock @@ -0,0 +1,20 @@ +{ + "_meta": { + "hash": { + "sha256": "415dfdcb118dd9bdfef17671cb7dcd78dbd69b6ae7d4f39e8b44e71d60ca72e7" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": {}, + "develop": {} +} diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml new file mode 100644 index 000000000..d4b18e8c5 --- /dev/null +++ b/docker/dev/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3.7" + +services: + db: + image: postgres:11.4 + env_file: config.env + volumes: + - db-data:/var/lib/postgresql/data + tgbot: + restart: on-failure + depends_on: + - db + build: + context: ../../ + dockerfile: ./docker/dev/Dockerfile + ports: + - "5003:5003" + env_file: config.env + volumes: + - ../../:/tgbot + command: pipenv run python -m tg_bot + +volumes: + db-data: diff --git a/tg_bot/__init__.py b/tg_bot/__init__.py index 5850f417b..3e1baad45 100644 --- a/tg_bot/__init__.py +++ b/tg_bot/__init__.py @@ -3,6 +3,7 @@ import sys import telegram.ext as tg +from tg_bot._version import __version__ # enable logging logging.basicConfig( @@ -58,10 +59,10 @@ BAN_STICKER = os.environ.get('BAN_STICKER', 'CAADAgADOwADPPEcAXkko5EB3YGYAg') ALLOW_EXCL = os.environ.get('ALLOW_EXCL', False) DEFAULT_CHAT_ID = os.environ.get('DEFAULT_CHAT_ID', None) + VERSION = __version__ else: from tg_bot.config import Development as Config - from tg_bot._version import __version__ TOKEN = Config.API_KEY try: OWNER_ID = int(Config.OWNER_ID) diff --git a/tg_bot/modules/spam.py b/tg_bot/modules/spam.py index 1ba1e7111..72bfd1058 100644 --- a/tg_bot/modules/spam.py +++ b/tg_bot/modules/spam.py @@ -10,6 +10,9 @@ @run_async @bot_can_delete def spam_filter(bot: Bot, update: Update): + """ + Filter messages with spam into message's text + """ msg = update.effective_message.text message_entities = update.effective_message.parse_entities() message_caption_entities = update.effective_message.parse_caption_entities()