mirror of
https://github.com/RYGhub/royalnet.git
synced 2025-03-31 04:10:31 +00:00
Fix /vote command 2
This commit is contained in:
parent
beae00c105
commit
723df5e540
2 changed files with 27 additions and 26 deletions
51
db.py
51
db.py
|
@ -692,33 +692,34 @@ class VoteQuestion(Base):
|
||||||
return f"<Vote {self.id}>"
|
return f"<Vote {self.id}>"
|
||||||
|
|
||||||
def generate_text(self, session: Session):
|
def generate_text(self, session: Session):
|
||||||
query = session.execute("SELECT * FROM telegram LEFT JOIN (SELECT voteanswer.question_id, voteanswer.user_id, voteanswer.choice FROM votequestion JOIN voteanswer ON votequestion.id = voteanswer.question_id WHERE votequestion.message_id = " + str(self.message_id) + ") answer ON telegram.telegram_id = answer.user_id ORDER BY answer.choice;")
|
|
||||||
text = f"<b>{self.question}</b>\n\n"
|
text = f"<b>{self.question}</b>\n\n"
|
||||||
none, yes, no, abstain = 0, 0, 0, 0
|
none, yes, no, abstain = 0, 0, 0, 0
|
||||||
for record in query:
|
if self.message_id is not None:
|
||||||
if record["username"] == "royalgamesbot":
|
query = session.execute("SELECT * FROM telegram LEFT JOIN (SELECT voteanswer.question_id, voteanswer.user_id, voteanswer.choice FROM votequestion JOIN voteanswer ON votequestion.id = voteanswer.question_id WHERE votequestion.message_id = " + str(self.message_id) + ") answer ON telegram.telegram_id = answer.user_id ORDER BY answer.choice;")
|
||||||
continue
|
for record in query:
|
||||||
elif record["question_id"] is None:
|
if record["username"] == "royalgamesbot":
|
||||||
text += "⚪️"
|
continue
|
||||||
none += 1
|
elif record["question_id"] is None:
|
||||||
elif record["choice"] == "YES":
|
text += "⚪️"
|
||||||
text += "🔵"
|
none += 1
|
||||||
yes += 1
|
elif record["choice"] == "YES":
|
||||||
elif record["choice"] == "NO":
|
text += "🔵"
|
||||||
text += "🔴"
|
yes += 1
|
||||||
no += 1
|
elif record["choice"] == "NO":
|
||||||
elif record["choice"] == "ABSTAIN":
|
text += "🔴"
|
||||||
text += "⚫️"
|
no += 1
|
||||||
abstain += 1
|
elif record["choice"] == "ABSTAIN":
|
||||||
if not self.anonymous:
|
text += "⚫️"
|
||||||
text += f" {str(record['username'])}\n"
|
abstain += 1
|
||||||
if self.anonymous:
|
if not self.anonymous:
|
||||||
text += "\n"
|
text += f" {str(record['username'])}\n"
|
||||||
text += f"\n" \
|
if self.anonymous:
|
||||||
f"⚪ {none}\n" \
|
text += "\n"
|
||||||
f"🔵 {yes}\n" \
|
text += f"\n" \
|
||||||
f"🔴 {no}\n" \
|
f"⚪ {none}\n" \
|
||||||
f"⚫️ {abstain}"
|
f"🔵 {yes}\n" \
|
||||||
|
f"🔴 {no}\n" \
|
||||||
|
f"⚫@roy️ {abstain}"
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ def cmd_vote(bot: Bot, update: Update):
|
||||||
parse_mode="HTML")
|
parse_mode="HTML")
|
||||||
vote.message_id = message.message_id
|
vote.message_id = message.message_id
|
||||||
session.commit()
|
session.commit()
|
||||||
except Exception:
|
except Exception as e:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
session.close()
|
session.close()
|
||||||
|
|
Loading…
Add table
Reference in a new issue