Compare commits

...

50 Commits
main ... dev

Author SHA1 Message Date
2b017c02d6 Merge pull request 'Update dependency async_pymongo to v0.1.11' (#34) from renovate/async_pymongo-0.x into dev
Reviewed-on: #34
2024-10-17 09:56:02 +03:00
d632201f65 Update dependency async_pymongo to v0.1.11 2024-10-16 20:14:07 +03:00
3b3f39a8f6 Merge pull request 'Update dependency async_pymongo to v0.1.10' (#33) from renovate/async_pymongo-0.x into dev
Reviewed-on: #33
2024-10-15 16:25:26 +03:00
dd1ce61cd1 Update dependency async_pymongo to v0.1.10 2024-10-15 13:09:26 +03:00
a4a95a61e2 Merge pull request 'Update dependency async_pymongo to v0.1.9' (#32) from renovate/async_pymongo-0.x into dev
Reviewed-on: #32
2024-10-08 16:49:41 +03:00
9b4df44564 Update dependency async_pymongo to v0.1.9 2024-10-08 16:29:37 +03:00
247c670b2e Merge pull request 'Update dependency async_pymongo to v0.1.8' (#31) from renovate/async_pymongo-0.x into dev
Reviewed-on: #31
2024-09-25 22:25:38 +03:00
00d6418c88 Update dependency async_pymongo to v0.1.8 2024-09-25 17:13:25 +03:00
a559f4c319 Merge pull request 'Update dependency async_pymongo to v0.1.7' (#30) from renovate/async_pymongo-0.x into dev
Reviewed-on: #30
2024-09-21 01:52:50 +03:00
91ad1baafa Update dependency async_pymongo to v0.1.7 2024-09-20 17:24:42 +03:00
8832ba89e4 Merge pull request 'Update dependency fastapi to ~=0.115.0' (#29) from renovate/fastapi-0.x into dev
Reviewed-on: #29
2024-09-18 09:24:41 +03:00
7102ba5922 Update dependency fastapi to ~=0.115.0 2024-09-18 00:37:16 +03:00
c679af095d Merge pull request 'Update dependency deepl to v1.19.1' (#28) from renovate/deepl-1.x into dev
Reviewed-on: #28
2024-09-18 00:01:50 +03:00
6f644b5236 Update dependency deepl to v1.19.1 2024-09-17 13:06:18 +03:00
c85140ee8b Update dependency pyrmv to v0.4.0 (#27) 2024-09-08 03:20:28 +03:00
63ac55d831 Update dependency pyrmv to v0.4.0 2024-09-08 03:05:11 +03:00
a2ebfe5867 Merge pull request 'Update dependency fastapi to ~=0.114.0' (#26) from renovate/fastapi-0.x into dev
Reviewed-on: #26
2024-09-07 11:31:01 +03:00
76074a46b8 Update dependency fastapi to ~=0.114.0 2024-09-06 20:51:34 +03:00
3d1d7e2701 Merge pull request 'Update dependency fastapi to ~=0.112.0' (#25) from renovate/fastapi-0.x into dev
Reviewed-on: #25
2024-08-03 00:58:30 +03:00
46bb3db995 Update dependency fastapi to ~=0.112.0 2024-08-02 09:57:19 +03:00
b6fb7e51b4 Merge pull request 'Update dependency libbot to v3.2.3' (#24) from renovate/libbot-3.x into dev
Reviewed-on: #24
2024-07-10 08:12:41 +03:00
f91ed1fba4 Update dependency libbot to v3.2.3 2024-07-10 00:44:02 +03:00
dc63cbb563 Merge pull request 'Update dependency async_pymongo to v0.1.6' (#23) from renovate/async_pymongo-0.x into dev
Reviewed-on: #23
2024-06-23 14:33:54 +03:00
87c3a3cea2 Update dependency async_pymongo to v0.1.6 2024-06-23 13:30:25 +03:00
80b2f47403 Merge pull request 'Update dependency async_pymongo to v0.1.5' (#22) from renovate/async_pymongo-0.x into dev
Reviewed-on: #22
2024-06-02 12:57:29 +03:00
9708fd6c2f Selected async_pymongo from PyPi 2024-06-02 12:56:30 +03:00
1bc84f0fcb Update dependency async_pymongo to v0.1.5 2024-06-01 15:32:29 +03:00
beb542b834 Merge pull request 'Update dependency libbot to v3.2.2' (#21) from renovate/libbot-3.x into dev
Reviewed-on: #21
2024-05-26 23:58:34 +03:00
8f599c776a Update dependency libbot to v3.2.2 2024-05-26 23:13:04 +03:00
a352da2f3e Merge pull request 'Update dependency libbot to v3.2.0' (#20) from renovate/libbot-3.x into dev
Reviewed-on: #20
2024-05-26 19:40:28 +03:00
2a7f582dd8 Update dependency libbot to v3.2.1 2024-05-26 19:01:56 +03:00
1e09ea7ec6 Merge pull request 'Update dependency libbot to v3.1.0' (#19) from renovate/libbot-3.x into dev
Reviewed-on: #19
2024-05-24 22:46:52 +03:00
c6e048177e Update dependency libbot to v3.1.0 2024-05-24 22:42:35 +03:00
331184a7fd Update dependency mongodb-migrations to v1.3.1 (#17) 2024-05-14 01:48:11 +03:00
00642835bd Update dependency mongodb-migrations to v1.3.1 2024-05-14 01:26:11 +03:00
bbe72f2fdf Update dependency fastapi to ~=0.111.0 (#16) 2024-05-03 11:42:55 +03:00
c7c46060e8 Update dependency fastapi to ~=0.111.0 2024-05-03 04:06:30 +03:00
da969dad58 Update dependency deepl to v1.18.0 (#15) 2024-04-26 16:54:19 +03:00
dd368733d4 Update dependency deepl to v1.18.0 2024-04-26 14:00:04 +03:00
6bfc329666 Merge pull request 'Update dependency fastapi to ~=0.110.0' (#14) from renovate/fastapi-0.x into dev
Reviewed-on: #14
2024-02-25 22:31:42 +02:00
edfd739023 Update dependency fastapi to ~=0.110.0 2024-02-25 02:13:58 +02:00
e2c05f3bf6
WIP: #9 2024-02-19 23:09:00 +01:00
fe4dcc4a92
Message events initialized 2024-02-19 23:08:41 +01:00
d5691c2bbb
Fixed scheduler-related issues 2024-02-19 23:07:38 +01:00
40376d2e6d Merge pull request 'Update dependency deepl to v1.17.0' (#7) from renovate/deepl-1.x into dev
Reviewed-on: #7
2024-02-13 19:05:55 +02:00
507c9dc9ed Update dependency deepl to v1.17.0 2024-02-07 13:53:18 +02:00
4d178bc3f2 Merge pull request 'Intial en locale addition' (#2) from i18n into dev
Reviewed-on: #2
2024-02-04 02:13:29 +02:00
Weblate
00f907c09c Translated using Weblate (German)
Currently translated at 100.0% (0 of 0 strings)

Added translation using Weblate (German)

Co-authored-by: Anonymous <noreply@weblate.org>
Co-authored-by: Profitroll <vozhd.kk@gmail.com>
Co-authored-by: Weblate <noreply@weblate.org>
Translate-URL: https://weblate.end-play.xyz/projects/hessenuk/javelina/de/
Translation: Hessenuk/Javelina
2024-02-04 02:12:27 +02:00
Weblate
45573c48ae Translated using Weblate (English)
Currently translated at 73.0% (38 of 52 strings)

Co-authored-by: Anonymous <noreply@weblate.org>
Translate-URL: https://weblate.end-play.xyz/projects/hessenuk/javelina/en/
Translation: Hessenuk/Javelina
2024-02-04 02:12:07 +02:00
57a5b5b4b3
Fixed uk and added en 2024-02-04 01:11:47 +01:00
12 changed files with 338 additions and 8 deletions

View File

@ -0,0 +1 @@
from .message_events import MessageEvents

View File

@ -0,0 +1,5 @@
from enum import Enum
class MessageEvents(Enum):
WEATHER_FORECAST = 0

View File

@ -14,6 +14,9 @@ class PycordBot(LibPycordBot):
self.client_session = ClientSession() self.client_session = ClientSession()
if self.scheduler is None:
return
# Scheduler job for DHL parcel tracking # Scheduler job for DHL parcel tracking
self.scheduler.add_job( self.scheduler.add_job(
update_tracks_dhl, update_tracks_dhl,
@ -40,6 +43,8 @@ class PycordBot(LibPycordBot):
async def close(self, *args: Any, **kwargs: Any) -> None: async def close(self, *args: Any, **kwargs: Any) -> None:
await self.client_session.close() await self.client_session.close()
if self.scheduler is not None:
self.scheduler.shutdown() self.scheduler.shutdown()
await super().close(*args, **kwargs) await super().close(*args, **kwargs)

View File

@ -0,0 +1,9 @@
from dataclasses import dataclass
@dataclass
class PycordGuildColors:
default: str
success: str
warning: str
error: str

94
locale/de.json Normal file
View File

@ -0,0 +1,94 @@
{
"actions": {
"bite": {
"name": "Вкусити",
"text": "**{user_name}** робить кусь **{target_name}**"
},
"poke": {
"name": "Тикнути",
"text": "**{user_name}** тикає в **{target_name}**"
},
"hug": {
"name": "Обійняти",
"text": "**{user_name}** обіймає **{target_name}**"
},
"kiss": {
"name": "Поцілувати",
"text": "**{user_name}** цілує **{target_name}**"
},
"lick": {
"name": "Лизнути",
"text": "**{user_name}** лиже **{target_name}**"
},
"pat": {
"name": "Погладити",
"text": "**{user_name}** гладить **{target_name}**"
},
"wave": {
"name": "Помахати",
"text": "**{user_name}** махає **{target_name}**"
},
"wink": {
"name": "Підморгнути",
"text": "**{user_name}** підморгує **{target_name}**"
}
},
"messages": {
"welcome": {
"morning": [
"{0} Добрий ранок та ласкаво просимо! {1}",
"{0} Доброго ранку та ласкаво просимо! {1}",
"{0} Вітаннячко! Ласкаво просимо! {1}",
"{0} Доброго ранку! Ласкаво просимо! {1}"
],
"midday": [
"{0} Добрий день! Ласкаво просимо! {1}",
"{0} Добридень! Ласкаво просимо! {1}",
"{0} День добрий! Ласкаво просимо! {1}",
"{0} Мої вітання! Ласкаво просимо! {1}",
"{0} Здоровенькі були! Ласкаво просимо! {1}",
"{0} Раді вітати вас! Ласкаво просимо! {1}",
"{0} Доброго здоров’ячка! Ласкаво просимо! {1}"
],
"evening": [
"{0} Добрий вечір! Ласкаво просимо! {1}",
"{0} Доброго вечора! Ласкаво просимо! {1}",
"{0} Добривечір! Ласкаво просимо! {1}",
"{0} Доброго вечора та ласкаво просимо! {1}",
"{0} Добрий вечір та ласкаво просимо! {1}"
],
"night": [
"{0} Доброї ночі! Ласкаво просимо! {1}",
"{0} Здоровенькі були! Ласкаво просимо! {1}"
],
"unknown": [
"{0} Вітаннячко! Ласкаво просимо! {1}"
]
}
},
"tracking": {
"dhl": {
"statuses": {
"delivered": "Доставлено",
"transit": "Транзит",
"pre-transit": "Пре-транзит",
"failure": "Невдача"
},
"messages": {
"DHL PAKET (parcel)": "DHL PAKET (посилка)",
"The shipment was prepared for onward transport.": "Вантаж підготовлено до подальшого транспортування.",
"Warenpost (Merchandise Shipment)": "Варенпост (відвантаження товарів)",
"The shipment has been processed in the parcel center": "Відправлення пройшло обробку в посилковому центрі",
"Unfortunately, the shipment could not be delivered today due to a strike action.": "На жаль, сьогодні вантаж не вдалося доставити через страйк.",
"Die Sendung wurde von DHL abgeholt.": "Відправлення забрала компанія DHL.",
"The shipment has been successfully delivered": "Відправлення успішно доставлено",
"The shipment could not be delivered, and the recipient has been notified": "Відправлення не вдалося доставити, одержувача було повідомлено про це",
"The shipment has been loaded onto the delivery vehicle": "Вантаж завантажено на транспортний засіб доставки",
"The shipment arrived in the region of recipient and will be transported to the delivery base in the next step.": "Відправлення прибуло в регіон одержувача і буде доставлено на базу доставки на наступному кроці",
"The shipment has been processed in the parcel center of origin": "Відправлення оброблено в центрі відправлення посилок",
"The shipment has been posted by the sender at the retail outlet": "Відправлення відправлено відправником у торговій точці",
"The instruction data for this shipment have been provided by the sender to DHL electronically": "Дані інструкцій для цього відправлення були надані DHL відправником в електронному вигляді"
}
}
}
}

94
locale/en.json Normal file
View File

@ -0,0 +1,94 @@
{
"messages": {
"welcome": {
"morning": [
"{0} Good morning and welcome! {1}",
"{0} Доброго ранку та ласкаво просимо! {1}",
"{0} Вітаннячко! Ласкаво просимо! {1}",
"{0} Доброго ранку! Ласкаво просимо! {1}"
],
"midday": [
"{0} Good day and welcome! {1}",
"{0} Добридень! Ласкаво просимо! {1}",
"{0} День добрий! Ласкаво просимо! {1}",
"{0} Мої вітання! Ласкаво просимо! {1}",
"{0} Здоровенькі були! Ласкаво просимо! {1}",
"{0} Раді вітати вас! Ласкаво просимо! {1}",
"{0} Доброго здоров’ячка! Ласкаво просимо! {1}"
],
"evening": [
"{0} Good evening and welcome! {1}",
"{0} Доброго вечора! Ласкаво просимо! {1}",
"{0} Добривечір! Ласкаво просимо! {1}",
"{0} Доброго вечора та ласкаво просимо! {1}",
"{0} Добрий вечір та ласкаво просимо! {1}"
],
"night": [
"{0} Good night and welcome! {1}",
"{0} Здоровенькі були! Ласкаво просимо! {1}"
],
"unknown": [
"{0} Hello and welcome! {1}"
]
}
},
"actions": {
"bite": {
"name": "Bite",
"text": "**{user_name}** bites **{target_name}**"
},
"hug": {
"name": "Hug",
"text": "**{user_name}** hugs **{target_name}**"
},
"kiss": {
"name": "Kiss",
"text": "**{user_name}** kisses **{target_name}**"
},
"lick": {
"name": "Lick",
"text": "**{user_name}** licks **{target_name}**"
},
"pat": {
"name": "Pat",
"text": "**{user_name}** pats **{target_name}**"
},
"poke": {
"name": "Poke",
"text": "**{user_name}** pokes **{target_name}**"
},
"wave": {
"name": "Wave",
"text": "**{user_name}** waves **{target_name}**"
},
"wink": {
"name": "Wink",
"text": "**{user_name}** winks **{target_name}**"
}
},
"tracking": {
"dhl": {
"statuses": {
"delivered": "Delivered",
"transit": "Transit",
"pre-transit": "Pre-transit",
"failure": "Failure"
},
"messages": {
"DHL PAKET (parcel)": "DHL PAKET (parcel)",
"The shipment was prepared for onward transport.": "The shipment was prepared for onward transport.",
"Warenpost (Merchandise Shipment)": "Warenpost (Merchandise Shipment)",
"The shipment has been processed in the parcel center": "The shipment has been processed in the parcel center",
"Unfortunately, the shipment could not be delivered today due to a strike action.": "Unfortunately, the shipment could not be delivered today due to a strike action.",
"Die Sendung wurde von DHL abgeholt.": "The shipment has been picked up by DHL.",
"The shipment has been successfully delivered": "The shipment has been successfully delivered",
"The shipment could not be delivered, and the recipient has been notified": "The shipment could not be delivered, and the recipient has been notified",
"The shipment has been loaded onto the delivery vehicle": "The shipment has been loaded onto the delivery vehicle",
"The shipment arrived in the region of recipient and will be transported to the delivery base in the next step.": "The shipment arrived in the region of recipient and will be transported to the delivery base in the next step.",
"The shipment has been processed in the parcel center of origin": "The shipment has been processed in the parcel center of origin",
"The shipment has been posted by the sender at the retail outlet": "The shipment has been posted by the sender at the retail outlet",
"The instruction data for this shipment have been provided by the sender to DHL electronically": "The instruction data for this shipment have been provided by the sender to DHL electronically"
}
}
}
}

View File

@ -38,7 +38,7 @@
"text": "**{user_name}** робить кусь **{target_name}**" "text": "**{user_name}** робить кусь **{target_name}**"
}, },
"hug": { "hug": {
"name": "", "name": "Обійняти",
"text": "**{user_name}** обіймає **{target_name}**" "text": "**{user_name}** обіймає **{target_name}**"
}, },
"kiss": { "kiss": {

View File

@ -24,6 +24,7 @@ db_client = AsyncClient(con_string)
db: AsyncDatabase = db_client.get_database(name=db_config["name"]) db: AsyncDatabase = db_client.get_database(name=db_config["name"])
col_users: AsyncCollection = db.get_collection("users") col_users: AsyncCollection = db.get_collection("users")
col_messages: AsyncCollection = db.get_collection("messages")
col_warnings: AsyncCollection = db.get_collection("warnings") col_warnings: AsyncCollection = db.get_collection("warnings")
col_checkouts: AsyncCollection = db.get_collection("checkouts") col_checkouts: AsyncCollection = db.get_collection("checkouts")
col_trackings: AsyncCollection = db.get_collection("trackings") col_trackings: AsyncCollection = db.get_collection("trackings")

View File

@ -0,0 +1,6 @@
def hex_to_int(hex_color: str) -> int:
return int(hex_color.lstrip("#"), 16)
def int_to_hex(integer_color: int) -> str:
return "#" + format(integer_color, "06x")

View File

@ -0,0 +1,9 @@
from typing import Any, Dict
def parse_weather(api_response: Dict[str, Any]) -> str:
return ""
def parse_weather_current(api_response: Dict[str, Any]) -> str:
return ""

106
modules/weather/reporter.py Normal file
View File

@ -0,0 +1,106 @@
from datetime import datetime
import logging
from typing import Any, Dict, List
from discord import Embed
from pymongo import DESCENDING
from pytz import timezone
from classes.enums import MessageEvents
from classes.pycordbot import PycordBot
from ujson import loads
from modules.utils import hex_to_int
from database import col_messages
from modules.weather.parser import parse_weather
# Example guild key
# "forecast": {
# "channel": 0,
# "time": "10:00:00",
# "delete_previous": true
# "locations": [{"name": "Sample Location", "location": [10.000, 20.000]}],
# }
logger = logging.getLogger(__name__)
async def report_weather(
bot: PycordBot,
guild: PycordGuild, # TODO
channel_id: int,
delete_previous: bool,
locations: List[Dict[str, Any]],
) -> None: # sourcery skip: aware-datetime-for-utc
channel = bot.get_channel(channel_id)
if channel is None:
logger.error(
"Cannot generate weather report for %s's channel %s because channel was not found.",
guild.id,
channel_id,
)
return
# Find and delete previous forecast, if needed
if delete_previous:
async for event in col_messages.find(
{
"event": MessageEvents.WEATHER_FORECAST,
"guild": guild.id,
"channel": channel_id,
},
limit=1,
).sort("date", direction=DESCENDING):
try:
old_message = bot.get_message(event["message"])
if old_message is not None:
await old_message.delete(
reason="Cleanup of the old weather report (look in guild config for details)"
)
except Exception as exc:
logger.warning(
"Could not delete the previous weather report in %s' channel %s due to %s",
guild.id,
channel_id,
exc,
)
embeds: List[Embed] = []
# Iterate through the locations and request their forecasts.
# Results must be parsed and added as embeds to the embeds lits.
for location in locations:
location_timezone_offset = ":".join(
str(
timezone(bot.config["bot"]["timezone"]).utcoffset(datetime.utcnow())
).split(":")[:2]
)
api_response = await (
await bot.client_session.get(
f"https://api.openweathermap.org/data/2.5/onecall?lat={location['location'][0]}&lon={location['location'][1]}&exclude=minutely&units=metric&lang=uk&appid={bot.config['modules']['weather']['forecasts']['api_key']}&tz={location_timezone_offset}"
)
).json(loads=loads)
parsed_weather = parse_weather(api_response)
embeds.append(
Embed(
title=location["name"],
description=parsed_weather,
color=hex_to_int(guild.colors.default),
)
)
# Add a trailing embed with OWM information
embeds.append(
Embed(
title=bot._("weather_report_title", "embeds"),
description=bot._("weather_report_description", "embeds"),
color=hex_to_int(guild.colors.default),
)
)
await channel.send( # type: ignore
content=bot._("weather_report_content", "messages"), embeds=embeds
)

View File

@ -1,12 +1,12 @@
aiohttp>=3.6.0 aiohttp>=3.6.0
apscheduler~=3.10.4 apscheduler~=3.10.4
async_pymongo==0.1.11
colorthief==0.2.1 colorthief==0.2.1
deepl==1.16.1 deepl==1.19.1
fastapi[all]~=0.109.1 fastapi[all]~=0.115.0
mongodb-migrations==1.3.0 mongodb-migrations==1.3.1
pynacl~=1.5.0 pynacl~=1.5.0
pyrmv==0.3.5 pyrmv==0.4.0
pytz~=2024.1 pytz~=2024.1
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple --extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
async_pymongo==0.1.4 libbot[speed,pycord]==3.2.3
libbot[speed,pycord]==3.0.0