From 6ec151835de8b6b1eaf10fa4635a069d08dd117b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 2 Apr 2019 19:52:50 +0200 Subject: [PATCH] Updates to Diario --- royalnet/commands/diario.py | 8 ++++++-- royalnet/database/tables/diario.py | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/royalnet/commands/diario.py b/royalnet/commands/diario.py index c2537fc8..f6a65867 100644 --- a/royalnet/commands/diario.py +++ b/royalnet/commands/diario.py @@ -1,4 +1,5 @@ from ..utils import Command, CommandArgs, Call +import re class DiarioCommand(Command): @@ -7,5 +8,8 @@ class DiarioCommand(Command): command_title = "Aggiungi una citazione al Diario." async def common(self, call: Call, args: CommandArgs): - # TODO - raise NotImplementedError("TODO") + # Recreate the full sentence + text = " ".join(args) + # Pass the sentence through the diario regex + match = re.match(r'["«‘“‛‟❛❝〝"`]([^"]+)["»’”❜❞〞"`] *(?:(?:-{1,2}|—) *(\w+))?(?:,? *([^ ].*))?', text) + # TODO \ No newline at end of file diff --git a/royalnet/database/tables/diario.py b/royalnet/database/tables/diario.py index ba80fce8..8335c458 100644 --- a/royalnet/database/tables/diario.py +++ b/royalnet/database/tables/diario.py @@ -3,7 +3,8 @@ from sqlalchemy import Column, \ Text, \ Boolean, \ DateTime, \ - ForeignKey + ForeignKey, \ + String from sqlalchemy.orm import relationship from .royals import Royal @@ -15,9 +16,11 @@ class Diario: creator_id = Column(Integer, ForeignKey("royals.id")) quoted_id = Column(Integer, ForeignKey("royals.id")) - timestamp = Column(DateTime, nullable=False) - quote = Column(Text, nullable=False) + quoted_name = Column(String) + text = Column(Text, nullable=False) context = Column(Text) + timestamp = Column(DateTime, nullable=False) + media_url = Column(String) spoiler = Column(Boolean, default=False) creator = relationship("Royal", foreign_keys=creator_id, backref="diario_created")