mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
PEP8
This commit is contained in:
parent
332e87120f
commit
22d1d15f05
2 changed files with 16 additions and 5 deletions
|
@ -79,7 +79,8 @@ class DiarioCommand(Command):
|
||||||
quoted_alias = None
|
quoted_alias = None
|
||||||
quoted_account = quoted_alias.royal if quoted_alias is not None else 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:
|
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!")
|
await call.reply("⚠️ Il nome dell'autore è ambiguo, quindi la riga non è stata aggiunta.\n"
|
||||||
|
"Per piacere, ripeti il comando con un nome più specifico!")
|
||||||
return
|
return
|
||||||
# Create the diario quote
|
# Create the diario quote
|
||||||
diario = call.alchemy.Diario(creator=creator,
|
diario = call.alchemy.Diario(creator=creator,
|
||||||
|
@ -132,7 +133,9 @@ class DiarioCommand(Command):
|
||||||
if not (text or media_url):
|
if not (text or media_url):
|
||||||
raise InvalidInputError("Missing text.")
|
raise InvalidInputError("Missing text.")
|
||||||
# Find the Royalnet account associated with the sender
|
# Find the Royalnet account associated with the sender
|
||||||
quoted_tg = await asyncify(call.session.query(call.alchemy.Telegram).filter_by(tg_id=reply.from_user.id).one_or_none)
|
quoted_tg = await asyncify(call.session.query(call.alchemy.Telegram)
|
||||||
|
.filter_by(tg_id=reply.from_user.id)
|
||||||
|
.one_or_none)
|
||||||
quoted_account = quoted_tg.royal if quoted_tg is not None else None
|
quoted_account = quoted_tg.royal if quoted_tg is not None else None
|
||||||
# Find the quoted name to assign
|
# Find the quoted name to assign
|
||||||
quoted_user: telegram.User = reply.from_user
|
quoted_user: telegram.User = reply.from_user
|
||||||
|
@ -178,7 +181,8 @@ class DiarioCommand(Command):
|
||||||
# Find if there's a Royalnet account associated with the quoted name
|
# Find if there's a Royalnet account associated with the quoted name
|
||||||
if quoted is not None:
|
if quoted is not None:
|
||||||
quoted_alias = await asyncify(
|
quoted_alias = await asyncify(
|
||||||
call.session.query(call.alchemy.Alias).filter_by(alias=quoted.lower()).one_or_none)
|
call.session.query(call.alchemy.Alias)
|
||||||
|
.filter_by(alias=quoted.lower()).one_or_none)
|
||||||
else:
|
else:
|
||||||
quoted_alias = None
|
quoted_alias = None
|
||||||
quoted_account = quoted_alias.royal if quoted_alias is not None else None
|
quoted_account = quoted_alias.royal if quoted_alias is not None else None
|
||||||
|
|
|
@ -60,10 +60,17 @@ class Diario:
|
||||||
return relationship("Royal", foreign_keys=self.quoted_account_id, backref="diario_quoted")
|
return relationship("Royal", foreign_keys=self.quoted_account_id, backref="diario_quoted")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"<Diario diario_id={self.diario_id} creator_id={self.creator_id} quoted_account_id={self.quoted_account_id} quoted={self.quoted} text={self.text} context={self.context} timestamp={self.timestamp} media_url={self.media_url} spoiler={self.spoiler}>"
|
return f"<Diario diario_id={self.diario_id}" \
|
||||||
|
f" creator_id={self.creator_id}" \
|
||||||
|
f" quoted_account_id={self.quoted_account_id}" \
|
||||||
|
f" quoted={self.quoted}" \
|
||||||
|
f" text={self.text}" \
|
||||||
|
f" context={self.context}" \
|
||||||
|
f" timestamp={self.timestamp}" \
|
||||||
|
f" media_url={self.media_url}" \
|
||||||
|
f" spoiler={self.spoiler}>"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# TODO: support media_url
|
|
||||||
text = f"Riga #{self.diario_id}"
|
text = f"Riga #{self.diario_id}"
|
||||||
text += f" (salvata da {str(self.creator)}"
|
text += f" (salvata da {str(self.creator)}"
|
||||||
text += f" il {self.timestamp.strftime('%Y-%m-%d %H:%M')}):\n"
|
text += f" il {self.timestamp.strftime('%Y-%m-%d %H:%M')}):\n"
|
||||||
|
|
Loading…
Reference in a new issue