Compare commits
No commits in common. "renovate/deepl-1.x" and "main" have entirely different histories.
renovate/d
...
main
@ -1 +0,0 @@
|
||||
from .message_events import MessageEvents
|
@ -1,5 +0,0 @@
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class MessageEvents(Enum):
|
||||
WEATHER_FORECAST = 0
|
@ -14,9 +14,6 @@ class PycordBot(LibPycordBot):
|
||||
|
||||
self.client_session = ClientSession()
|
||||
|
||||
if self.scheduler is None:
|
||||
return
|
||||
|
||||
# Scheduler job for DHL parcel tracking
|
||||
self.scheduler.add_job(
|
||||
update_tracks_dhl,
|
||||
@ -43,8 +40,6 @@ class PycordBot(LibPycordBot):
|
||||
|
||||
async def close(self, *args: Any, **kwargs: Any) -> None:
|
||||
await self.client_session.close()
|
||||
|
||||
if self.scheduler is not None:
|
||||
self.scheduler.shutdown()
|
||||
|
||||
await super().close(*args, **kwargs)
|
||||
|
@ -1,9 +0,0 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class PycordGuildColors:
|
||||
default: str
|
||||
success: str
|
||||
warning: str
|
||||
error: str
|
@ -1,94 +0,0 @@
|
||||
{
|
||||
"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 відправником в електронному вигляді"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@
|
||||
"text": "**{user_name}** робить кусь **{target_name}**"
|
||||
},
|
||||
"hug": {
|
||||
"name": "Обійняти",
|
||||
"name": "",
|
||||
"text": "**{user_name}** обіймає **{target_name}**"
|
||||
},
|
||||
"kiss": {
|
||||
|
@ -24,7 +24,6 @@ db_client = AsyncClient(con_string)
|
||||
db: AsyncDatabase = db_client.get_database(name=db_config["name"])
|
||||
|
||||
col_users: AsyncCollection = db.get_collection("users")
|
||||
col_messages: AsyncCollection = db.get_collection("messages")
|
||||
col_warnings: AsyncCollection = db.get_collection("warnings")
|
||||
col_checkouts: AsyncCollection = db.get_collection("checkouts")
|
||||
col_trackings: AsyncCollection = db.get_collection("trackings")
|
||||
|
@ -1,6 +0,0 @@
|
||||
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")
|
@ -1,9 +0,0 @@
|
||||
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 ""
|
@ -1,106 +0,0 @@
|
||||
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
|
||||
)
|
@ -1,12 +1,12 @@
|
||||
aiohttp>=3.6.0
|
||||
apscheduler~=3.10.4
|
||||
async_pymongo==0.1.11
|
||||
colorthief==0.2.1
|
||||
deepl==1.20.0
|
||||
fastapi[all]~=0.115.0
|
||||
mongodb-migrations==1.3.1
|
||||
deepl==1.16.1
|
||||
fastapi[all]~=0.109.1
|
||||
mongodb-migrations==1.3.0
|
||||
pynacl~=1.5.0
|
||||
pyrmv==0.4.0
|
||||
pyrmv==0.3.5
|
||||
pytz~=2024.1
|
||||
--extra-index-url https://git.end-play.xyz/api/packages/profitroll/pypi/simple
|
||||
libbot[speed,pycord]==3.2.3
|
||||
async_pymongo==0.1.4
|
||||
libbot[speed,pycord]==3.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user