From 0e85dfaf3e91b8616ba54ad39e51bb5f690cdab9 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 8 Feb 2019 01:44:48 +0100 Subject: [PATCH] Prevent circular import --- db.py | 10 ++++------ strings.py | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/db.py b/db.py index 26892d30..48b51a5d 100644 --- a/db.py +++ b/db.py @@ -19,7 +19,6 @@ import sql_queries from flask import escape import configparser import typing -import strings if typing.TYPE_CHECKING: # noinspection PyPackageRequirements from discord import User as DiscordUser @@ -837,11 +836,10 @@ class Diario(Base): return f"{self.id} - {self.timestamp} - {self.author}: {self.text}" def to_telegram(self): - return strings.safely_format_string(strings.DIARIO.ENTRY, words={ - "id": self.id, - "author": self.author, - "text": self.text - }) + return '#{id} di {author}\n{text}'.format( + id=self.id, + author=self.author, + text=escape(self.text)) def to_html(self): return str(escape(self.text)).replace("\n", "
") diff --git a/strings.py b/strings.py index d9f80333..997cec06 100644 --- a/strings.py +++ b/strings.py @@ -32,7 +32,7 @@ PONG = "🏓 Pong!" # Diario class DIARIO: SUCCESS = "✅ Riga aggiunta al diario:\n{diario}" - ENTRY = '#{id} di {author}\n{text}' + ENTRY = class ERRORS: INVALID_SYNTAX = "⚠ Sintassi del comando errata.\nSintassi: /diario (frase), oppure rispondi a un messaggio con /diario."