diff --git a/requirements.txt b/requirements.txt index 483e63f5..75e6bd32 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ python-telegram-bot>=11.1.0 websockets>=7.0 pytest>=4.3.1 +psycopg2-binary>=2.8 diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 3af8100d..9595ab0a 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -63,8 +63,8 @@ class TelegramBot: .replace("[/i]", "") \ .replace("[u]", "") \ .replace("[/u]", "") \ - .replace("[c]", "
") \ - .replace("[/c]", "") + .replace("[c]", "
") \
+ .replace("[/c]", "
")
await asyncify(call.channel.send_message, escaped_text, parse_mode="HTML")
async def net_request(call, message: Message, destination: str):
diff --git a/royalnet/commands/debug_author.py b/royalnet/commands/debug_author.py
index e3b3285c..0c7bfdcd 100644
--- a/royalnet/commands/debug_author.py
+++ b/royalnet/commands/debug_author.py
@@ -14,4 +14,4 @@ class DebugAuthorCommand(Command):
author = await call.get_author()
if author is None:
await call.reply(f"βοΈ L'autore di questa chiamata Γ¨ sconosciuto.")
- await call.reply(f"π [c]{str(author)}[/c] Γ¨ l'autore di questa chiamata.")
+ await call.reply(f"π {str(author)} Γ¨ l'autore di questa chiamata.")
diff --git a/royalnet/commands/debug_create.py b/royalnet/commands/debug_create.py
index 4804a2ab..46ddb39e 100644
--- a/royalnet/commands/debug_create.py
+++ b/royalnet/commands/debug_create.py
@@ -13,7 +13,7 @@ class DebugCreateCommand(Command):
async def common(self, call: Call):
royal = call.alchemy.Royal(username=call.args[0], role="Member")
call.session.add(royal)
- alias = call.alchemy.Alias(royal=royal, alias=royal.username)
+ alias = call.alchemy.Alias(royal=royal, alias=royal.username.lower())
call.session.add(alias)
await asyncify(call.session.commit)
- await call.reply(f"β
Utente [c]{royal}[/c] creato!")
+ await call.reply(f"β
Utente {royal} creato!")
diff --git a/royalnet/commands/diario.py b/royalnet/commands/diario.py
index 55f35574..9f589595 100644
--- a/royalnet/commands/diario.py
+++ b/royalnet/commands/diario.py
@@ -9,7 +9,7 @@ class DiarioCommand(Command):
command_name = "diario"
command_title = "Aggiungi una citazione al Diario."
- command_syntax = "\"(testo)\" --[autore], [contesto]"
+ command_syntax = "[!] \"(testo)\" --[autore], [contesto]"
require_alchemy_tables = {Royal, Diario, Alias}
@@ -36,12 +36,23 @@ class DiarioCommand(Command):
quoted = None
context = None
timestamp = datetime.datetime.now()
+ # Ensure there is some text
+ if not text:
+ raise InvalidInputError("Missing text.")
+ # Or a quoted
+ if not quoted:
+ quoted = None
+ if not context:
+ context = None
# Find if there's a Royalnet account associated with the quoted name
if quoted is not None:
quoted_alias = await asyncify(call.session.query(call.alchemy.Alias).filter_by(alias=quoted.lower()).one_or_none)
else:
quoted_alias = None
quoted_account = quoted_alias.royal if quoted_alias is not None else None
+ if quoted_alias is not None and quoted_account is None:
+ await call.reply("β οΈ Il nome dell'autore Γ¨ ambiguo, quindi la riga non Γ¨ stata aggiunta.\nPer piacere, ripeti il comando con un nome piΓΉ specifico!")
+ return
# Create the diario quote
diario = call.alchemy.Diario(creator=creator,
quoted_account=quoted_account,
diff --git a/royalnet/commands/sync.py b/royalnet/commands/sync.py
index f4863834..9f2e287b 100644
--- a/royalnet/commands/sync.py
+++ b/royalnet/commands/sync.py
@@ -37,13 +37,13 @@ class SyncCommand(Command):
tg_last_name=user.last_name,
tg_username=user.username)
call.session.add(telegram)
- await call.reply(f"β
Connessione completata: [c]{str(royal)}[/c] β¬ [c]{str(telegram)}[/c]")
+ await call.reply(f"β
Connessione completata: {str(royal)} β¬ {str(telegram)}")
else:
# Update the Telegram data
# Avatar is WIP
telegram.tg_first_name = user.first_name
telegram.tg_last_name = user.last_name
telegram.tg_username = user.username
- await call.reply(f"β
Dati di [c]{str(telegram)}[/c] aggiornati.")
+ await call.reply(f"β
Dati di {str(telegram)} aggiornati.")
# Commit the session
await asyncify(call.session.commit)
diff --git a/royalnet/database/tables/diario.py b/royalnet/database/tables/diario.py
index 720789e4..7758e88b 100644
--- a/royalnet/database/tables/diario.py
+++ b/royalnet/database/tables/diario.py
@@ -32,15 +32,15 @@ class Diario:
def __str__(self):
# TODO: support media_url
text = f"Riga #{self.diario_id}"
- text += f" (salvata da {self.creator.username}"
- text += f" alle {self.timestamp.strftime('%Y-%m-%d %H:%M')}):\n"
+ text += f" (salvata da {str(self.creator)}"
+ text += f" il {self.timestamp.strftime('%Y-%m-%d %H:%M')}):\n"
if self.spoiler:
hidden = re.sub("\w", "β", self.text)
text += f"\"{hidden}\"\n"
else:
text += f"[b]\"{self.text}\"[/b]\n"
if self.quoted_account is not None:
- text += f" β{self.quoted_account.username}"
+ text += f" β{str(self.quoted_account)}"
elif self.quoted is not None:
text += f" β{self.quoted}"
else:
diff --git a/royalnet/database/tables/royals.py b/royalnet/database/tables/royals.py
index 180720bc..63a85f1b 100644
--- a/royalnet/database/tables/royals.py
+++ b/royalnet/database/tables/royals.py
@@ -17,4 +17,4 @@ class Royal:
return f"