Migrate to beanie

This commit is contained in:
Zeva Rose 2023-08-27 14:13:20 -06:00
parent 2208930b4e
commit 211c3f4d5b
8 changed files with 221 additions and 201 deletions

28
.flake8
View file

@ -1,20 +1,20 @@
[flake8] [flake8]
exclude = exclude =
run.py tests/*
extend-ignore = extend-ignore =
Q0, E501, C812, E203, W503, # These default to arguing with Black. We might configure some of them eventually Q0, E501, C812, E203, W503,
ANN001, # Ignore self and cls annotations ANN1, ANN003,
ANN002, ANN003, # Ignore *args and **kwargs ANN204, ANN206,
ANN101, # Ignore self D105, D107,
ANN204, ANN206, # return annotations for special methods and class methods S311,
D105, D107, # Missing Docstrings in magic method and __init__ D401,
S311, # Standard pseudo-random generators are not suitable for security/cryptographic purposes. D400,
D401, # First line should be in imperative mood; try rephrasing D101, D102,
D400, # First line should end with a period D106,
D101, # Missing docstring in public class R503, E712
# 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 max-line-length=100
per-file-ignores =
jarvis_core/db/models/__init__.py:F401

View file

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0 rev: v4.4.0
hooks: hooks:
- id: check-toml - id: check-toml
- id: check-yaml - id: check-yaml
@ -9,21 +9,19 @@ repos:
- id: requirements-txt-fixer - id: requirements-txt-fixer
- id: end-of-file-fixer - id: end-of-file-fixer
- id: debug-statements - id: debug-statements
language_version: python3.10
- id: trailing-whitespace - id: trailing-whitespace
args: [--markdown-linebreak-ext=md] args: [--markdown-linebreak-ext=md]
- repo: https://github.com/pre-commit/pygrep-hooks - repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0 rev: v1.10.0
hooks: hooks:
- id: python-check-blanket-noqa - id: python-check-blanket-noqa
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 22.3.0 rev: 23.7.0
hooks: hooks:
- id: black - id: black
args: [--line-length=100, --target-version=py310] args: [--line-length=100]
language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-isort - repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1 rev: v5.10.1
@ -32,12 +30,12 @@ repos:
args: ["--profile", "black"] args: ["--profile", "black"]
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 4.0.1 rev: 6.1.0
hooks: hooks:
- id: flake8 - id: flake8
additional_dependencies: additional_dependencies:
- flake8-annotations~=2.0 - flake8-annotations~=2.0
#- flake8-bandit~=2.1 #- flake8-bandit # Uncomment once works again
- flake8-docstrings~=1.5 - flake8-docstrings~=1.5
- flake8-bugbear - flake8-bugbear
- flake8-comprehensions - flake8-comprehensions
@ -46,4 +44,3 @@ repos:
- flake8-deprecated - flake8-deprecated
- flake8-print - flake8-print
- flake8-return - flake8-return
language_version: python3.10

View file

@ -1,23 +1,19 @@
"""JARVIS background tasks.""" """JARVIS background tasks."""
import asyncio import asyncio
from typing import Optional
from interactions import Client, Intents
from jarvis_core.db import connect from jarvis_core.db import connect
from jarvis_core.log import get_logger from jarvis_core.log import get_logger
from interactions import Client, Intents
from jarvis_tasks import const from jarvis_tasks import const
from jarvis_tasks.config import load_config from jarvis_tasks.config import load_config
from jarvis_tasks.prometheus.serve import StatTracker
from jarvis_tasks.tasks import ( from jarvis_tasks.tasks import (
autokick, autokick,
ban, ban,
lock, lock,
lockdown, lockdown,
reddit,
reminder, reminder,
temprole, temprole,
twitter,
warning, warning,
) )
@ -48,7 +44,7 @@ async def _start() -> None:
bot = Client(intents=intents, loop=loop) bot = Client(intents=intents, loop=loop)
await bot.login(config.token) await bot.login(config.token)
logger.info(f"Logged in as {bot.user.username}#{bot.user.discriminator}") logger.info(f"Logged in as {bot.user.username}#{bot.user.discriminator}")
tracker = StatTracker() # tracker = StatTracker()
# Start tasks # Start tasks
try: try:
@ -58,10 +54,8 @@ async def _start() -> None:
ban.unban, ban.unban,
lock.unlock, lock.unlock,
lockdown.lift, lockdown.lift,
reddit.reddit,
reminder.remind, reminder.remind,
temprole.remove, temprole.remove,
# twitter.twitter,
warning.unwarn, warning.unwarn,
] ]
tasks = [loop.create_task(f(bot)) for f in functions] + [ tasks = [loop.create_task(f(bot)) for f in functions] + [

View file

@ -4,8 +4,8 @@ from os import environ
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
import yaml
import orjson as json import orjson as json
import yaml
from dotenv import load_dotenv from dotenv import load_dotenv
from jarvis_core.util import find_all from jarvis_core.util import find_all
from pydantic import BaseModel from pydantic import BaseModel
@ -32,31 +32,11 @@ class Mongo(BaseModel):
port: int = 27017 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): class Config(BaseModel):
"""Tasks config model.""" """Tasks config model."""
token: str token: str
mongo: Mongo mongo: Mongo
reddit: Optional[Reddit] = None
twitter: Optional[Twitter] = None
log_level: str = "INFO" log_level: str = "INFO"
environment: Environment = Environment.develop environment: Environment = Environment.develop
@ -66,39 +46,27 @@ _config: Config = None
def _load_json() -> Config | None: def _load_json() -> Config | None:
path = Path("config.json") path = Path("config.json")
config = None
if path.exists(): if path.exists():
with path.open() as f: with path.open() as f:
j = json.loads(f.read()) j = json.loads(f.read())
config = Config(**j) return Config(**j)
return config
def _load_yaml() -> Config | None: def _load_yaml() -> Config | None:
path = Path("config.yaml") path = Path("config.yaml")
config = None
if path.exists(): if path.exists():
with path.open() as f: with path.open() as f:
y = yaml.load(f.read(), Loader=Loader) y = yaml.load(f.read(), Loader=Loader)
config = Config(**y) return Config(**y)
return config
def _load_env() -> Config | None: def _load_env() -> Config | None:
load_dotenv() load_dotenv()
data = {} data = {}
mongo = {} mongo = {}
twitter = {}
reddit = {}
mongo_keys = find_all(lambda x: x.upper().startswith("MONGO"), environ.keys()) 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 = ( config_keys = mongo_keys + ["TOKEN", "LOG_LEVEL", "ENVIRONMENT"]
mongo_keys + reddit_keys + twitter_keys + ["TOKEN", "LOG_LEVEL", "ENVIRONMENT"]
)
for item, value in environ.items(): for item, value in environ.items():
if item not in config_keys: if item not in config_keys:
@ -107,20 +75,10 @@ def _load_env() -> Config | None:
if item in mongo_keys: if item in mongo_keys:
key = "_".join(item.split("_")[1:]).lower() key = "_".join(item.split("_")[1:]).lower()
mongo[key] = value 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: else:
data[item.lower()] = value data[item.lower()] = value
data["mongo"] = mongo 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) return Config(**data)

View file

@ -1,15 +1,17 @@
"""JARVIS reminders.""" """JARVIS reminders."""
import asyncio import asyncio
import logging import logging
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta
from typing import Optional from typing import Optional
from beanie.operators import NotIn, LTE import pytz
from jarvis_core.db.models import Reminder from beanie.operators import LTE, NotIn
from croniter import croniter
from interactions import Client from interactions import Client
from interactions.models.discord.channel import GuildText from interactions.models.discord.channel import GuildText
from interactions.models.discord.embed import Embed from interactions.models.discord.embed import Embed
from interactions.models.discord.user import User 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.prometheus.stats import reminder_count
from jarvis_tasks.util import build_embed, runat from jarvis_tasks.util import build_embed, runat
@ -55,15 +57,21 @@ async def _remind(
await reminder.save() await reminder.save()
delete = False delete = False
else: else:
logger.warning( logger.warning(f"Reminder {reminder.id} failed, no way to contact user.")
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: if delete:
await reminder.delete() await reminder.delete()
else:
await reminder.save()
if reminded: if reminded:
count = reminder_count.labels( guild_id = channel.guild.id if channel.guild else user.id
guild_id=channel.guild.id, guild_name=channel.guild.name 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() count.inc()
queue.remove(reminder.id) queue.remove(reminder.id)
@ -77,7 +85,7 @@ async def remind(bot: Client) -> None:
""" """
logger.debug("Starting Task-remind") logger.debug("Starting Task-remind")
while True: 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( reminders = Reminder.find(
NotIn(Reminder.id, queue), NotIn(Reminder.id, queue),
LTE(Reminder.remind_at, max_ts), LTE(Reminder.remind_at, max_ts),

147
poetry.lock generated
View file

@ -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]] [[package]]
name = "aiofiles" name = "aiofiles"
version = "0.8.0" version = "0.8.0"
description = "File support for asyncio." description = "File support for asyncio."
category = "main"
optional = false optional = false
python-versions = ">=3.6,<4.0" python-versions = ">=3.6,<4.0"
files = [ files = [
@ -16,7 +15,6 @@ files = [
name = "aiohttp" name = "aiohttp"
version = "3.8.4" version = "3.8.4"
description = "Async http client/server framework (asyncio)" description = "Async http client/server framework (asyncio)"
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -125,7 +123,6 @@ speedups = ["Brotli", "aiodns", "cchardet"]
name = "aiosignal" name = "aiosignal"
version = "1.3.1" version = "1.3.1"
description = "aiosignal: a list of registered asynchronous callbacks" description = "aiosignal: a list of registered asynchronous callbacks"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -140,7 +137,6 @@ frozenlist = ">=1.1.0"
name = "aiosqlite" name = "aiosqlite"
version = "0.17.0" version = "0.17.0"
description = "asyncio bridge to the standard sqlite3 module" description = "asyncio bridge to the standard sqlite3 module"
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -155,7 +151,6 @@ typing_extensions = ">=3.7.2"
name = "asgiref" name = "asgiref"
version = "3.6.0" version = "3.6.0"
description = "ASGI specs, helper code, and adapters" description = "ASGI specs, helper code, and adapters"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -170,7 +165,6 @@ tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"]
name = "async-generator" name = "async-generator"
version = "1.10" version = "1.10"
description = "Async generators and context managers for Python 3.5+" description = "Async generators and context managers for Python 3.5+"
category = "main"
optional = false optional = false
python-versions = ">=3.5" python-versions = ">=3.5"
files = [ files = [
@ -182,7 +176,6 @@ files = [
name = "async-lru" name = "async-lru"
version = "2.0.2" version = "2.0.2"
description = "Simple LRU cache for asyncio" description = "Simple LRU cache for asyncio"
category = "main"
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
files = [ files = [
@ -197,7 +190,6 @@ typing-extensions = ">=4.0.0"
name = "async-timeout" name = "async-timeout"
version = "4.0.2" version = "4.0.2"
description = "Timeout context manager for asyncio programs" description = "Timeout context manager for asyncio programs"
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -209,7 +201,6 @@ files = [
name = "asyncio-extras" name = "asyncio-extras"
version = "1.3.2" version = "1.3.2"
description = "Asynchronous generators, context managers and more for asyncio" description = "Asynchronous generators, context managers and more for asyncio"
category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
@ -228,7 +219,6 @@ test = ["pytest", "pytest-asyncio", "pytest-cov"]
name = "asyncpraw" name = "asyncpraw"
version = "7.7.0" 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." 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 optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -246,16 +236,15 @@ update-checker = ">=0.18"
[package.extras] [package.extras]
ci = ["coveralls"] 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"] lint = ["pre-commit", "sphinx", "sphinx-rtd-dark-mode", "sphinx-rtd-theme", "sphinxcontrib-trio"]
readthedocs = ["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]] [[package]]
name = "asyncprawcore" name = "asyncprawcore"
version = "2.3.0" version = "2.3.0"
description = "Low-level asynchronous communication layer for Async PRAW 7+." description = "Low-level asynchronous communication layer for Async PRAW 7+."
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -277,7 +266,6 @@ test = ["asynctest (>=0.13.0)", "mock (>=0.8)", "pytest", "pytest-vcr", "testfix
name = "attrs" name = "attrs"
version = "23.1.0" version = "23.1.0"
description = "Classes Without Boilerplate" description = "Classes Without Boilerplate"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -296,7 +284,6 @@ tests-no-zope = ["cloudpickle", "hypothesis", "mypy (>=1.1.1)", "pympler", "pyte
name = "black" name = "black"
version = "22.12.0" version = "22.12.0"
description = "The uncompromising code formatter." description = "The uncompromising code formatter."
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -331,7 +318,6 @@ uvloop = ["uvloop (>=0.15.2)"]
name = "certifi" name = "certifi"
version = "2023.5.7" version = "2023.5.7"
description = "Python package for providing Mozilla's CA Bundle." description = "Python package for providing Mozilla's CA Bundle."
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -343,7 +329,6 @@ files = [
name = "charset-normalizer" name = "charset-normalizer"
version = "3.1.0" version = "3.1.0"
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
category = "main"
optional = false optional = false
python-versions = ">=3.7.0" python-versions = ">=3.7.0"
files = [ files = [
@ -428,7 +413,6 @@ files = [
name = "click" name = "click"
version = "8.1.3" version = "8.1.3"
description = "Composable command line interface toolkit" description = "Composable command line interface toolkit"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -443,7 +427,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""}
name = "colorama" name = "colorama"
version = "0.4.6" version = "0.4.6"
description = "Cross-platform colored terminal text." description = "Cross-platform colored terminal text."
category = "main"
optional = false optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7"
files = [ files = [
@ -455,7 +438,6 @@ files = [
name = "commonmark" name = "commonmark"
version = "0.9.1" version = "0.9.1"
description = "Python parser for the CommonMark Markdown spec" description = "Python parser for the CommonMark Markdown spec"
category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
@ -466,11 +448,24 @@ files = [
[package.extras] [package.extras]
test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] 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]] [[package]]
name = "discord-typings" name = "discord-typings"
version = "0.5.1" version = "0.5.1"
description = "Maintained typings of payloads that Discord sends" description = "Maintained typings of payloads that Discord sends"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -485,7 +480,6 @@ typing_extensions = ">=4.3,<5"
name = "dnspython" name = "dnspython"
version = "2.3.0" version = "2.3.0"
description = "DNS toolkit" description = "DNS toolkit"
category = "main"
optional = false optional = false
python-versions = ">=3.7,<4.0" python-versions = ">=3.7,<4.0"
files = [ files = [
@ -506,7 +500,6 @@ wmi = ["wmi (>=1.5.1,<2.0.0)"]
name = "emoji" name = "emoji"
version = "2.2.0" version = "2.2.0"
description = "Emoji for Python" description = "Emoji for Python"
category = "main"
optional = false optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
files = [ files = [
@ -520,7 +513,6 @@ dev = ["coverage", "coveralls", "pytest"]
name = "exceptiongroup" name = "exceptiongroup"
version = "1.1.1" version = "1.1.1"
description = "Backport of PEP 654 (exception groups)" description = "Backport of PEP 654 (exception groups)"
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -535,7 +527,6 @@ test = ["pytest (>=6)"]
name = "frozenlist" name = "frozenlist"
version = "1.3.3" version = "1.3.3"
description = "A list-like structure which implements collections.abc.MutableSequence" description = "A list-like structure which implements collections.abc.MutableSequence"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -619,7 +610,6 @@ files = [
name = "h11" name = "h11"
version = "0.14.0" version = "0.14.0"
description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -631,7 +621,6 @@ files = [
name = "idna" name = "idna"
version = "3.4" version = "3.4"
description = "Internationalized Domain Names in Applications (IDNA)" description = "Internationalized Domain Names in Applications (IDNA)"
category = "main"
optional = false optional = false
python-versions = ">=3.5" python-versions = ">=3.5"
files = [ files = [
@ -643,7 +632,6 @@ files = [
name = "iniconfig" name = "iniconfig"
version = "2.0.0" version = "2.0.0"
description = "brain-dead simple config-ini parsing" description = "brain-dead simple config-ini parsing"
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -655,7 +643,6 @@ files = [
name = "interactions-py" name = "interactions-py"
version = "5.3.1" version = "5.3.1"
description = "Easy, simple, scalable and modular: a Python API wrapper for interactions." description = "Easy, simple, scalable and modular: a Python API wrapper for interactions."
category = "main"
optional = false optional = false
python-versions = ">=3.10" python-versions = ">=3.10"
files = [ files = [
@ -685,7 +672,6 @@ voice = ["PyNaCl (>=1.5.0,<1.6)"]
name = "jarvis-core" name = "jarvis-core"
version = "0.16.1" version = "0.16.1"
description = "JARVIS core" description = "JARVIS core"
category = "main"
optional = false optional = false
python-versions = "^3.10" python-versions = "^3.10"
files = [] files = []
@ -712,7 +698,6 @@ resolved_reference = "ec4219e5a54bea78ff19f23f1754a036e8d0eae3"
name = "marshmallow" name = "marshmallow"
version = "3.19.0" version = "3.19.0"
description = "A lightweight library for converting complex datatypes to and from native Python datatypes." description = "A lightweight library for converting complex datatypes to and from native Python datatypes."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -733,7 +718,6 @@ tests = ["pytest", "pytz", "simplejson"]
name = "motor" name = "motor"
version = "3.1.2" version = "3.1.2"
description = "Non-blocking MongoDB driver for Tornado or asyncio" description = "Non-blocking MongoDB driver for Tornado or asyncio"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -757,7 +741,6 @@ zstd = ["pymongo[zstd] (>=4.1,<5)"]
name = "multidict" name = "multidict"
version = "6.0.4" version = "6.0.4"
description = "multidict implementation" description = "multidict implementation"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -841,7 +824,6 @@ files = [
name = "mypy-extensions" name = "mypy-extensions"
version = "1.0.0" version = "1.0.0"
description = "Type system extensions for programs checked with the mypy type checker." description = "Type system extensions for programs checked with the mypy type checker."
category = "dev"
optional = false optional = false
python-versions = ">=3.5" python-versions = ">=3.5"
files = [ files = [
@ -853,7 +835,6 @@ files = [
name = "nanoid" name = "nanoid"
version = "2.0.0" version = "2.0.0"
description = "A tiny, secure, URL-friendly, unique string ID generator for Python" description = "A tiny, secure, URL-friendly, unique string ID generator for Python"
category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
@ -865,7 +846,6 @@ files = [
name = "oauthlib" name = "oauthlib"
version = "3.2.2" version = "3.2.2"
description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic" description = "A generic, spec-compliant, thorough implementation of the OAuth request-signing logic"
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -882,7 +862,6 @@ signedtoken = ["cryptography (>=3.0.0)", "pyjwt (>=2.0.0,<3)"]
name = "orjson" name = "orjson"
version = "3.8.12" version = "3.8.12"
description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy" description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -938,7 +917,6 @@ files = [
name = "packaging" name = "packaging"
version = "23.1" version = "23.1"
description = "Core utilities for Python packages" description = "Core utilities for Python packages"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -950,7 +928,6 @@ files = [
name = "pathspec" name = "pathspec"
version = "0.11.1" version = "0.11.1"
description = "Utility library for gitignore style pattern matching of file paths." description = "Utility library for gitignore style pattern matching of file paths."
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -962,7 +939,6 @@ files = [
name = "platformdirs" name = "platformdirs"
version = "3.5.0" version = "3.5.0"
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -978,7 +954,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-
name = "pluggy" name = "pluggy"
version = "1.0.0" version = "1.0.0"
description = "plugin and hook calling mechanisms for python" description = "plugin and hook calling mechanisms for python"
category = "dev"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -994,7 +969,6 @@ testing = ["pytest", "pytest-benchmark"]
name = "prometheus-client" name = "prometheus-client"
version = "0.14.1" version = "0.14.1"
description = "Python client for the Prometheus monitoring system." description = "Python client for the Prometheus monitoring system."
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -1009,7 +983,6 @@ twisted = ["twisted"]
name = "pydantic" name = "pydantic"
version = "1.10.7" version = "1.10.7"
description = "Data validation and settings management using python type hints" description = "Data validation and settings management using python type hints"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1062,7 +1035,6 @@ email = ["email-validator (>=1.0.3)"]
name = "pygments" name = "pygments"
version = "2.15.1" version = "2.15.1"
description = "Pygments is a syntax highlighting package written in Python." description = "Pygments is a syntax highlighting package written in Python."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1077,7 +1049,6 @@ plugins = ["importlib-metadata"]
name = "pymongo" name = "pymongo"
version = "4.3.3" version = "4.3.3"
description = "Python driver for MongoDB <http://www.mongodb.org>" description = "Python driver for MongoDB <http://www.mongodb.org>"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1172,7 +1143,6 @@ zstd = ["zstandard"]
name = "pytest" name = "pytest"
version = "7.3.1" version = "7.3.1"
description = "pytest: simple powerful testing with Python" description = "pytest: simple powerful testing with Python"
category = "dev"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1191,11 +1161,24 @@ tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""}
[package.extras] [package.extras]
testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] 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]] [[package]]
name = "python-dotenv" name = "python-dotenv"
version = "0.21.1" version = "0.21.1"
description = "Read key-value pairs from a .env file and set them as environment variables" description = "Read key-value pairs from a .env file and set them as environment variables"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1210,7 +1193,6 @@ cli = ["click (>=5.0)"]
name = "pytz" name = "pytz"
version = "2022.7.1" version = "2022.7.1"
description = "World timezone definitions, modern and historical" description = "World timezone definitions, modern and historical"
category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
@ -1222,7 +1204,6 @@ files = [
name = "pyyaml" name = "pyyaml"
version = "6.0" version = "6.0"
description = "YAML parser and emitter for Python" description = "YAML parser and emitter for Python"
category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
files = [ files = [
@ -1268,11 +1249,32 @@ files = [
{file = "PyYAML-6.0.tar.gz", hash = "sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2"}, {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]] [[package]]
name = "requests" name = "requests"
version = "2.30.0" version = "2.30.0"
description = "Python HTTP for Humans." description = "Python HTTP for Humans."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1294,7 +1296,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"]
name = "requests-oauthlib" name = "requests-oauthlib"
version = "1.3.1" version = "1.3.1"
description = "OAuthlib authentication support for Requests." description = "OAuthlib authentication support for Requests."
category = "main"
optional = false optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*"
files = [ files = [
@ -1313,7 +1314,6 @@ rsa = ["oauthlib[signedtoken] (>=3.0.0)"]
name = "rich" name = "rich"
version = "12.6.0" version = "12.6.0"
description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal"
category = "main"
optional = false optional = false
python-versions = ">=3.6.3,<4.0.0" python-versions = ">=3.6.3,<4.0.0"
files = [ files = [
@ -1328,11 +1328,41 @@ pygments = ">=2.6.0,<3.0.0"
[package.extras] [package.extras]
jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] 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]] [[package]]
name = "tomli" name = "tomli"
version = "2.0.1" version = "2.0.1"
description = "A lil' TOML parser" description = "A lil' TOML parser"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1344,7 +1374,6 @@ files = [
name = "tweepy" name = "tweepy"
version = "4.14.0" version = "4.14.0"
description = "Twitter library for Python" description = "Twitter library for Python"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1370,7 +1399,6 @@ test = ["vcrpy (>=1.10.3)"]
name = "typing-extensions" name = "typing-extensions"
version = "4.5.0" version = "4.5.0"
description = "Backported and Experimental Type Hints for Python 3.7+" description = "Backported and Experimental Type Hints for Python 3.7+"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1382,7 +1410,6 @@ files = [
name = "umongo" name = "umongo"
version = "3.1.0" version = "3.1.0"
description = "sync/async MongoDB ODM, yes." description = "sync/async MongoDB ODM, yes."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1403,7 +1430,6 @@ txmongo = ["txmongo (>=19.2.0)"]
name = "update-checker" name = "update-checker"
version = "0.18.0" version = "0.18.0"
description = "A python module that will check for package updates." description = "A python module that will check for package updates."
category = "main"
optional = false optional = false
python-versions = "*" python-versions = "*"
files = [ files = [
@ -1423,7 +1449,6 @@ test = ["pytest (>=2.7.3)"]
name = "urllib3" name = "urllib3"
version = "2.0.2" version = "2.0.2"
description = "HTTP library with thread-safe connection pooling, file post, and more." description = "HTTP library with thread-safe connection pooling, file post, and more."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1441,7 +1466,6 @@ zstd = ["zstandard (>=0.18.0)"]
name = "uvicorn" name = "uvicorn"
version = "0.17.6" version = "0.17.6"
description = "The lightning-fast ASGI server." description = "The lightning-fast ASGI server."
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1461,7 +1485,6 @@ standard = ["PyYAML (>=5.1)", "colorama (>=0.4)", "httptools (>=0.4.0)", "python
name = "yarl" name = "yarl"
version = "1.9.2" version = "1.9.2"
description = "Yet another URL library" description = "Yet another URL library"
category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
@ -1548,4 +1571,4 @@ multidict = ">=4.0"
[metadata] [metadata]
lock-version = "2.0" lock-version = "2.0"
python-versions = ">=3.10,<4" python-versions = ">=3.10,<4"
content-hash = "a73579b1ea2b00a08b8ce355213156911df93608c07fc7112944a1e29f1a31e1" content-hash = "a9f3ec22c6c8b3c281b9b3303736842cd4da4a10736fe27670146fde6c971c33"

View file

@ -1,23 +1,25 @@
[tool.poetry] [tool.poetry]
name = "jarvis-tasks" name = "jarvis-tasks"
version = "0.10.0" version = "0.11.0"
description = "" description = ""
authors = ["Your Name <you@example.com>"] authors = ["Zevaryx <zevaryx@gmail.com>"]
[tool.poetry.dependencies] [tool.poetry.dependencies]
python = ">=3.10,<4" 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" aiohttp = "^3.8.3"
tweepy = {extras = ["async"], version = "^4.13.0"} tweepy = { extras = ["async"], version = "^4.13.0" }
asyncpraw = "^7.5.0" asyncpraw = "^7.5.0"
uvicorn = "^0.17.6" uvicorn = "^0.17.6"
prometheus-client = "^0.14.1" prometheus-client = "^0.14.1"
interactions-py = "^5.3.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] [tool.poetry.dev-dependencies]
pytest = "^7.1" pytest = "^7.1"
black = {version = "^22.3.0", allow-prereleases = true} black = { version = "^22.3.0", allow-prereleases = true }
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]

38
sample.env Normal file
View file

@ -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=