From 211c3f4d5bdf86e6b867a32b6c55839c433f4750 Mon Sep 17 00:00:00 2001 From: zevaryx Date: Sun, 27 Aug 2023 14:13:20 -0600 Subject: [PATCH] Migrate to beanie --- .flake8 | 40 ++++----- .pre-commit-config.yaml | 95 +++++++++++---------- jarvis_tasks/__init__.py | 10 +-- jarvis_tasks/config.py | 50 +---------- jarvis_tasks/tasks/reminder.py | 28 ++++--- poetry.lock | 147 +++++++++++++++++++-------------- pyproject.toml | 14 ++-- sample.env | 38 +++++++++ 8 files changed, 221 insertions(+), 201 deletions(-) create mode 100644 sample.env diff --git a/.flake8 b/.flake8 index 4cc3c85..2a5bd3b 100644 --- a/.flake8 +++ b/.flake8 @@ -1,20 +1,20 @@ -[flake8] -exclude = - run.py - -extend-ignore = - Q0, E501, C812, E203, W503, # These default to arguing with Black. We might configure some of them eventually - ANN001, # Ignore self and cls annotations - ANN002, ANN003, # Ignore *args and **kwargs - ANN101, # Ignore self - ANN204, ANN206, # return annotations for special methods and class methods - D105, D107, # Missing Docstrings in magic method and __init__ - S311, # Standard pseudo-random generators are not suitable for security/cryptographic purposes. - D401, # First line should be in imperative mood; try rephrasing - D400, # First line should end with a period - D101, # Missing docstring in public class - - # Plugins we don't currently include: flake8-return - R503, # missing explicit return at the end of function ableto return non-None value. - -max-line-length=100 +[flake8] +exclude = + tests/* + +extend-ignore = + Q0, E501, C812, E203, W503, + ANN1, ANN003, + ANN204, ANN206, + D105, D107, + S311, + D401, + D400, + D101, D102, + D106, + R503, E712 + +max-line-length=100 + +per-file-ignores = + jarvis_core/db/models/__init__.py:F401 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 458d5b5..80a9854 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,49 +1,46 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 - hooks: - - id: check-toml - - id: check-yaml - args: [--unsafe] - - id: check-merge-conflict - - id: requirements-txt-fixer - - id: end-of-file-fixer - - id: debug-statements - language_version: python3.10 - - id: trailing-whitespace - args: [--markdown-linebreak-ext=md] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 - hooks: - - id: python-check-blanket-noqa - - - repo: https://github.com/psf/black - rev: 22.3.0 - hooks: - - id: black - args: [--line-length=100, --target-version=py310] - language_version: python3.10 - - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 - hooks: - - id: isort - args: ["--profile", "black"] - - - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 - hooks: - - id: flake8 - additional_dependencies: - - flake8-annotations~=2.0 - #- flake8-bandit~=2.1 - - flake8-docstrings~=1.5 - - flake8-bugbear - - flake8-comprehensions - - flake8-quotes - - flake8-raise - - flake8-deprecated - - flake8-print - - flake8-return - language_version: python3.10 +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-toml + - id: check-yaml + args: [--unsafe] + - id: check-merge-conflict + - id: requirements-txt-fixer + - id: end-of-file-fixer + - id: debug-statements + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-blanket-noqa + + - repo: https://github.com/psf/black + rev: 23.7.0 + hooks: + - id: black + args: [--line-length=100] + + - repo: https://github.com/pre-commit/mirrors-isort + rev: v5.10.1 + hooks: + - id: isort + args: ["--profile", "black"] + + - repo: https://github.com/pycqa/flake8 + rev: 6.1.0 + hooks: + - id: flake8 + additional_dependencies: + - flake8-annotations~=2.0 + #- flake8-bandit # Uncomment once works again + - flake8-docstrings~=1.5 + - flake8-bugbear + - flake8-comprehensions + - flake8-quotes + - flake8-raise + - flake8-deprecated + - flake8-print + - flake8-return diff --git a/jarvis_tasks/__init__.py b/jarvis_tasks/__init__.py index bcdf456..182ddfb 100644 --- a/jarvis_tasks/__init__.py +++ b/jarvis_tasks/__init__.py @@ -1,23 +1,19 @@ """JARVIS background tasks.""" import asyncio -from typing import Optional +from interactions import Client, Intents from jarvis_core.db import connect from jarvis_core.log import get_logger -from interactions import Client, Intents from jarvis_tasks import const from jarvis_tasks.config import load_config -from jarvis_tasks.prometheus.serve import StatTracker from jarvis_tasks.tasks import ( autokick, ban, lock, lockdown, - reddit, reminder, temprole, - twitter, warning, ) @@ -48,7 +44,7 @@ async def _start() -> None: bot = Client(intents=intents, loop=loop) await bot.login(config.token) logger.info(f"Logged in as {bot.user.username}#{bot.user.discriminator}") - tracker = StatTracker() + # tracker = StatTracker() # Start tasks try: @@ -58,10 +54,8 @@ async def _start() -> None: ban.unban, lock.unlock, lockdown.lift, - reddit.reddit, reminder.remind, temprole.remove, - # twitter.twitter, warning.unwarn, ] tasks = [loop.create_task(f(bot)) for f in functions] + [ diff --git a/jarvis_tasks/config.py b/jarvis_tasks/config.py index 0b5f9e2..6e683ca 100644 --- a/jarvis_tasks/config.py +++ b/jarvis_tasks/config.py @@ -4,8 +4,8 @@ from os import environ from pathlib import Path from typing import Optional -import yaml import orjson as json +import yaml from dotenv import load_dotenv from jarvis_core.util import find_all from pydantic import BaseModel @@ -32,31 +32,11 @@ class Mongo(BaseModel): port: int = 27017 -class Reddit(BaseModel): - """Reddit config.""" - - user_agent: Optional[str] = None - client_secret: str - client_id: str - - -class Twitter(BaseModel): - """Twitter config.""" - - consumer_key: str - consumer_secret: str - access_token: str - access_secret: str - bearer_token: str - - class Config(BaseModel): """Tasks config model.""" token: str mongo: Mongo - reddit: Optional[Reddit] = None - twitter: Optional[Twitter] = None log_level: str = "INFO" environment: Environment = Environment.develop @@ -66,39 +46,27 @@ _config: Config = None def _load_json() -> Config | None: path = Path("config.json") - config = None if path.exists(): with path.open() as f: j = json.loads(f.read()) - config = Config(**j) - - return config + return Config(**j) def _load_yaml() -> Config | None: path = Path("config.yaml") - config = None if path.exists(): with path.open() as f: y = yaml.load(f.read(), Loader=Loader) - config = Config(**y) - - return config + return Config(**y) def _load_env() -> Config | None: load_dotenv() data = {} mongo = {} - twitter = {} - reddit = {} mongo_keys = find_all(lambda x: x.upper().startswith("MONGO"), environ.keys()) - reddit_keys = find_all(lambda x: x.upper().startswith("REDDIT"), environ.keys()) - twitter_keys = find_all(lambda x: x.upper().startswith("TWITTER"), environ.keys()) - config_keys = ( - mongo_keys + reddit_keys + twitter_keys + ["TOKEN", "LOG_LEVEL", "ENVIRONMENT"] - ) + config_keys = mongo_keys + ["TOKEN", "LOG_LEVEL", "ENVIRONMENT"] for item, value in environ.items(): if item not in config_keys: @@ -107,20 +75,10 @@ def _load_env() -> Config | None: if item in mongo_keys: key = "_".join(item.split("_")[1:]).lower() mongo[key] = value - elif item in twitter_keys: - key = "_".join(item.split("_")[1:]).lower() - twitter[key] = value - elif item in reddit_keys: - key = "_".join(item.split("_")[1:]).lower() - reddit[key] = value else: data[item.lower()] = value data["mongo"] = mongo - if all(x is not None for x in reddit.values()): - data["reddit"] = reddit - if all(x is not None for x in twitter.values()): - data["twitter"] = twitter return Config(**data) diff --git a/jarvis_tasks/tasks/reminder.py b/jarvis_tasks/tasks/reminder.py index 9b285b5..5c306e9 100644 --- a/jarvis_tasks/tasks/reminder.py +++ b/jarvis_tasks/tasks/reminder.py @@ -1,15 +1,17 @@ """JARVIS reminders.""" import asyncio import logging -from datetime import datetime, timedelta, timezone +from datetime import datetime, timedelta from typing import Optional -from beanie.operators import NotIn, LTE -from jarvis_core.db.models import Reminder +import pytz +from beanie.operators import LTE, NotIn +from croniter import croniter from interactions import Client from interactions.models.discord.channel import GuildText from interactions.models.discord.embed import Embed from interactions.models.discord.user import User +from jarvis_core.db.models import Reminder from jarvis_tasks.prometheus.stats import reminder_count from jarvis_tasks.util import build_embed, runat @@ -55,15 +57,21 @@ async def _remind( await reminder.save() delete = False else: - logger.warning( - f"Reminder {reminder.id} failed, no way to contact user." - ) + logger.warning(f"Reminder {reminder.id} failed, no way to contact user.") + if reminder.repeat: + now = datetime.now(tz=pytz.timezone(reminder.timezone)) + cron = croniter(reminder.repeat, now) + reminder.remind_at = cron.next(datetime) + reminder.total_reminders += 1 + delete = False if delete: await reminder.delete() + else: + await reminder.save() if reminded: - count = reminder_count.labels( - guild_id=channel.guild.id, guild_name=channel.guild.name - ) + guild_id = channel.guild.id if channel.guild else user.id + guild_name = channel.guild.name if channel.guild else user.username + count = reminder_count.labels(guild_id=guild_id, guild_name=guild_name) count.inc() queue.remove(reminder.id) @@ -77,7 +85,7 @@ async def remind(bot: Client) -> None: """ logger.debug("Starting Task-remind") while True: - max_ts = datetime.now(tz=timezone.utc) + timedelta(seconds=5) + max_ts = datetime.now(tz=pytz.utc) + timedelta(seconds=5) reminders = Reminder.find( NotIn(Reminder.id, queue), LTE(Reminder.remind_at, max_ts), diff --git a/poetry.lock b/poetry.lock index a9e3eb1..5221872 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "aiofiles" version = "0.8.0" description = "File support for asyncio." -category = "main" optional = false python-versions = ">=3.6,<4.0" files = [ @@ -16,7 +15,6 @@ files = [ name = "aiohttp" version = "3.8.4" description = "Async http client/server framework (asyncio)" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -125,7 +123,6 @@ speedups = ["Brotli", "aiodns", "cchardet"] name = "aiosignal" version = "1.3.1" description = "aiosignal: a list of registered asynchronous callbacks" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -140,7 +137,6 @@ frozenlist = ">=1.1.0" name = "aiosqlite" version = "0.17.0" description = "asyncio bridge to the standard sqlite3 module" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -155,7 +151,6 @@ typing_extensions = ">=3.7.2" name = "asgiref" version = "3.6.0" description = "ASGI specs, helper code, and adapters" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -170,7 +165,6 @@ tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] name = "async-generator" version = "1.10" description = "Async generators and context managers for Python 3.5+" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -182,7 +176,6 @@ files = [ name = "async-lru" version = "2.0.2" description = "Simple LRU cache for asyncio" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -197,7 +190,6 @@ typing-extensions = ">=4.0.0" name = "async-timeout" version = "4.0.2" description = "Timeout context manager for asyncio programs" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -209,7 +201,6 @@ files = [ name = "asyncio-extras" version = "1.3.2" description = "Asynchronous generators, context managers and more for asyncio" -category = "main" optional = false python-versions = "*" files = [ @@ -228,7 +219,6 @@ test = ["pytest", "pytest-asyncio", "pytest-cov"] name = "asyncpraw" version = "7.7.0" description = "Async PRAW, an abbreviation for \"Asynchronous Python Reddit API Wrapper\", is a python package that allows for simple access to Reddit's API." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -246,16 +236,15 @@ update-checker = ">=0.18" [package.extras] ci = ["coveralls"] -dev = ["asynctest (>=0.13.0,<0.14.0)", "mock (>=4.0.0,<5.0.0)", "packaging", "pre-commit", "pytest (>=7.0.0,<8.0.0)", "pytest-asyncio (>=0.18.0,<0.19.0)", "pytest-vcr (>=1.0.0,<2.0.0)", "sphinx", "sphinx-rtd-dark-mode", "sphinx-rtd-theme", "sphinxcontrib-trio", "testfixtures (>=6.0.0,<7.0.0)", "vcrpy (>=4.0.0,<5.0.0)"] +dev = ["asynctest (==0.13.*)", "mock (==4.*)", "packaging", "pre-commit", "pytest (==7.*)", "pytest-asyncio (==0.18.*)", "pytest-vcr (==1.*)", "sphinx", "sphinx-rtd-dark-mode", "sphinx-rtd-theme", "sphinxcontrib-trio", "testfixtures (==6.*)", "vcrpy (==4.*)"] lint = ["pre-commit", "sphinx", "sphinx-rtd-dark-mode", "sphinx-rtd-theme", "sphinxcontrib-trio"] readthedocs = ["sphinx", "sphinx-rtd-dark-mode", "sphinx-rtd-theme", "sphinxcontrib-trio"] -test = ["asynctest (>=0.13.0,<0.14.0)", "mock (>=4.0.0,<5.0.0)", "pytest (>=7.0.0,<8.0.0)", "pytest-asyncio (>=0.18.0,<0.19.0)", "pytest-vcr (>=1.0.0,<2.0.0)", "testfixtures (>=6.0.0,<7.0.0)", "vcrpy (>=4.0.0,<5.0.0)"] +test = ["asynctest (==0.13.*)", "mock (==4.*)", "pytest (==7.*)", "pytest-asyncio (==0.18.*)", "pytest-vcr (==1.*)", "testfixtures (==6.*)", "vcrpy (==4.*)"] [[package]] name = "asyncprawcore" version = "2.3.0" description = "Low-level asynchronous communication layer for Async PRAW 7+." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -277,7 +266,6 @@ test = ["asynctest (>=0.13.0)", "mock (>=0.8)", "pytest", "pytest-vcr", "testfix name = "attrs" version = "23.1.0" description = "Classes Without Boilerplate" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -296,7 +284,6 @@ tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pyte name = "black" version = "22.12.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -331,7 +318,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "certifi" version = "2023.5.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -343,7 +329,6 @@ files = [ name = "charset-normalizer" version = "3.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -428,7 +413,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -443,7 +427,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "main" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -455,7 +438,6 @@ files = [ name = "commonmark" version = "0.9.1" description = "Python parser for the CommonMark Markdown spec" -category = "main" optional = false python-versions = "*" files = [ @@ -466,11 +448,24 @@ files = [ [package.extras] test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] +[[package]] +name = "croniter" +version = "1.4.1" +description = "croniter provides iteration for datetime object with cron like format" +optional = false +python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +files = [ + {file = "croniter-1.4.1-py2.py3-none-any.whl", hash = "sha256:9595da48af37ea06ec3a9f899738f1b2c1c13da3c38cea606ef7cd03ea421128"}, + {file = "croniter-1.4.1.tar.gz", hash = "sha256:1a6df60eacec3b7a0aa52a8f2ef251ae3dd2a7c7c8b9874e73e791636d55a361"}, +] + +[package.dependencies] +python-dateutil = "*" + [[package]] name = "discord-typings" version = "0.5.1" description = "Maintained typings of payloads that Discord sends" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -485,7 +480,6 @@ typing_extensions = ">=4.3,<5" name = "dnspython" version = "2.3.0" description = "DNS toolkit" -category = "main" optional = false python-versions = ">=3.7,<4.0" files = [ @@ -506,7 +500,6 @@ wmi = ["wmi (>=1.5.1,<2.0.0)"] name = "emoji" version = "2.2.0" description = "Emoji for Python" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -520,7 +513,6 @@ dev = ["coverage", "coveralls", "pytest"] name = "exceptiongroup" version = "1.1.1" description = "Backport of PEP 654 (exception groups)" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -535,7 +527,6 @@ test = ["pytest (>=6)"] name = "frozenlist" version = "1.3.3" description = "A list-like structure which implements collections.abc.MutableSequence" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -619,7 +610,6 @@ files = [ name = "h11" version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -631,7 +621,6 @@ files = [ name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -643,7 +632,6 @@ files = [ name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -655,7 +643,6 @@ files = [ name = "interactions-py" version = "5.3.1" description = "Easy, simple, scalable and modular: a Python API wrapper for interactions." -category = "main" optional = false python-versions = ">=3.10" files = [ @@ -685,7 +672,6 @@ voice = ["PyNaCl (>=1.5.0,<1.6)"] name = "jarvis-core" version = "0.16.1" description = "JARVIS core" -category = "main" optional = false python-versions = "^3.10" files = [] @@ -712,7 +698,6 @@ resolved_reference = "ec4219e5a54bea78ff19f23f1754a036e8d0eae3" name = "marshmallow" version = "3.19.0" description = "A lightweight library for converting complex datatypes to and from native Python datatypes." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -733,7 +718,6 @@ tests = ["pytest", "pytz", "simplejson"] name = "motor" version = "3.1.2" description = "Non-blocking MongoDB driver for Tornado or asyncio" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -757,7 +741,6 @@ zstd = ["pymongo[zstd] (>=4.1,<5)"] name = "multidict" version = "6.0.4" description = "multidict implementation" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -841,7 +824,6 @@ files = [ name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -853,7 +835,6 @@ files = [ name = "nanoid" version = "2.0.0" description = "A tiny, secure, URL-friendly, unique string ID generator for Python" -category = "main" optional = false python-versions = "*" files = [ @@ -865,7 +846,6 @@ files = [ name = "oauthlib" version = "3.2.2" description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -882,7 +862,6 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"] name = "orjson" version = "3.8.12" description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -938,7 +917,6 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -950,7 +928,6 @@ files = [ name = "pathspec" version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -962,7 +939,6 @@ files = [ name = "platformdirs" version = "3.5.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -978,7 +954,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest- name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -994,7 +969,6 @@ testing = ["pytest", "pytest-benchmark"] name = "prometheus-client" version = "0.14.1" description = "Python client for the Prometheus monitoring system." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -1009,7 +983,6 @@ twisted = ["twisted"] name = "pydantic" version = "1.10.7" description = "Data validation and settings management using python type hints" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1062,7 +1035,6 @@ email = ["email-validator (>=1.0.3)"] name = "pygments" version = "2.15.1" description = "Pygments is a syntax highlighting package written in Python." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1077,7 +1049,6 @@ plugins = ["importlib-metadata"] name = "pymongo" version = "4.3.3" description = "Python driver for MongoDB " -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1172,7 +1143,6 @@ zstd = ["zstandard"] name = "pytest" version = "7.3.1" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1191,11 +1161,24 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} [package.extras] testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] +[[package]] +name = "python-dateutil" +version = "2.8.2" +description = "Extensions to the standard Python datetime module" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" +files = [ + {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, + {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, +] + +[package.dependencies] +six = ">=1.5" + [[package]] name = "python-dotenv" version = "0.21.1" description = "Read key-value pairs from a .env file and set them as environment variables" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1210,7 +1193,6 @@ cli = ["click (>=5.0)"] name = "pytz" version = "2022.7.1" description = "World timezone definitions, modern and historical" -category = "main" optional = false python-versions = "*" files = [ @@ -1222,7 +1204,6 @@ files = [ name = "pyyaml" version = "6.0" description = "YAML parser and emitter for Python" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -1268,11 +1249,32 @@ files = [ {file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, ] +[[package]] +name = "redbird" +version = "0.7.1" +description = "Repository Patterns for Python" +optional = false +python-versions = ">=3.7" +files = [ + {file = "redbird-0.7.1-py3-none-any.whl", hash = "sha256:6a1fe83fa9dfc0c5b9cb256b54376c299c423f2daba7bcbc081a820ff5b3c6c1"}, + {file = "redbird-0.7.1.tar.gz", hash = "sha256:9ef1098f2a0e68afe40349475018f7694b05bdf92250772cd8d0126f26de58a9"}, +] + +[package.dependencies] +pydantic = "*" +typing-extensions = "*" + +[package.extras] +full = ["pydantic-sqlalchemy", "pymongo", "requests", "sqlalchemy"] +mongodb = ["pymongo"] +rest = ["requests"] +sql = ["pydantic-sqlalchemy", "sqlalchemy"] +test = ["mongomock", "pydantic-sqlalchemy", "pymongo", "pytest", "python-dotenv", "requests", "responses", "sqlalchemy"] + [[package]] name = "requests" version = "2.30.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1294,7 +1296,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "requests-oauthlib" version = "1.3.1" description = "OAuthlib authentication support for Requests." -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ @@ -1313,7 +1314,6 @@ rsa = ["oauthlib[signedtoken] (>=3.0.0)"] name = "rich" version = "12.6.0" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "main" optional = false python-versions = ">=3.6.3,<4.0.0" files = [ @@ -1328,11 +1328,41 @@ pygments = ">=2.6.0,<3.0.0" [package.extras] jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] +[[package]] +name = "rocketry" +version = "2.5.1" +description = "Advanced scheduling framework" +optional = false +python-versions = ">=3.7" +files = [ + {file = "rocketry-2.5.1-py3-none-any.whl", hash = "sha256:d8755e909026ba401174218bc0a0958044973244cd07e1405e80f85512440253"}, + {file = "rocketry-2.5.1.tar.gz", hash = "sha256:11d1fb3d2856c5b2727bb4814c4f2bfbd2803067eebeac872d34a4c7a6756825"}, +] + +[package.dependencies] +pydantic = "*" +python-dateutil = "*" +redbird = ">=0.5.0" + +[package.extras] +docs = ["pydata-sphinx-theme", "sphinx (>=1.7.5)", "sphinx-book-theme", "sphinx-copybutton", "sphinx-material"] +test = ["pytest", "pytest-asyncio"] + +[[package]] +name = "six" +version = "1.16.0" +description = "Python 2 and 3 compatibility utilities" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" +files = [ + {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, + {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, +] + [[package]] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1344,7 +1374,6 @@ files = [ name = "tweepy" version = "4.14.0" description = "Twitter library for Python" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1370,7 +1399,6 @@ test = ["vcrpy (>=1.10.3)"] name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1382,7 +1410,6 @@ files = [ name = "umongo" version = "3.1.0" description = "sync/async MongoDB ODM, yes." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1403,7 +1430,6 @@ txmongo = ["txmongo (>=19.2.0)"] name = "update-checker" version = "0.18.0" description = "A python module that will check for package updates." -category = "main" optional = false python-versions = "*" files = [ @@ -1423,7 +1449,6 @@ test = ["pytest (>=2.7.3)"] name = "urllib3" version = "2.0.2" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1441,7 +1466,6 @@ zstd = ["zstandard (>=0.18.0)"] name = "uvicorn" version = "0.17.6" description = "The lightning-fast ASGI server." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1461,7 +1485,6 @@ standard = ["PyYAML (>=5.1)", "colorama (>=0.4)", "httptools (>=0.4.0)", "python name = "yarl" version = "1.9.2" description = "Yet another URL library" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -1548,4 +1571,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.10,<4" -content-hash = "a73579b1ea2b00a08b8ce355213156911df93608c07fc7112944a1e29f1a31e1" +content-hash = "a9f3ec22c6c8b3c281b9b3303736842cd4da4a10736fe27670146fde6c971c33" diff --git a/pyproject.toml b/pyproject.toml index c814f39..ec55f99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,23 +1,25 @@ [tool.poetry] name = "jarvis-tasks" -version = "0.10.0" +version = "0.11.0" description = "" -authors = ["Your Name "] +authors = ["Zevaryx "] [tool.poetry.dependencies] python = ">=3.10,<4" -jarvis-core = {git = "https://git.zevaryx.com/stark-industries/jarvis/jarvis-core.git", rev = "main"} +jarvis-core = { git = "https://git.zevaryx.com/stark-industries/jarvis/jarvis-core.git", rev = "main" } aiohttp = "^3.8.3" -tweepy = {extras = ["async"], version = "^4.13.0"} +tweepy = { extras = ["async"], version = "^4.13.0" } asyncpraw = "^7.5.0" uvicorn = "^0.17.6" prometheus-client = "^0.14.1" interactions-py = "^5.3.1" -pydantic = "^1.10.7" +pydantic = ">=2.3.0,<3" +rocketry = "^2.5.1" +croniter = "^1.4.1" [tool.poetry.dev-dependencies] pytest = "^7.1" -black = {version = "^22.3.0", allow-prereleases = true} +black = { version = "^22.3.0", allow-prereleases = true } [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/sample.env b/sample.env new file mode 100644 index 0000000..a90f578 --- /dev/null +++ b/sample.env @@ -0,0 +1,38 @@ +# Base Config, required +TOKEN= + +# Base Config, optional +ENVIRONMENT=develop +SYNC=false +LOG_LEVEL=INFO +JURIGGED=false + +# MongoDB, required +MONGO_HOST=localhost +MONGO_USERNAME= +MONGO_PASSWORD= +MONGO_PORT=27017 + +# Redis, required +REDIS_HOST=localhost +REDIS_USERNAME= +REDIS_PASSWORD= + +# Mastodon, optional +MASTODON_TOKEN= +MASTODON_URL= + +# Reddit, optional +REDDIT_USER_AGENT= +REDDIT_CLIENT_SECRET= +REDDIT_CLIENT_ID= + +# Twitter, optional +TWITTER_CONSUMER_KEY= +TWITTER_CONSUMER_SECRET= +TWITTER_ACCESS_TOKEN= +TWITTER_ACCESS_SECRET= +TWITTER_BEARER_TOKEN= + +# URLs, optional +URL_DBRAND=