Added command list to banner

This commit is contained in:
2026-10-31 01:12:01 -05:00
parent d06c1dde15
commit ec7bb58c30
19 changed files with 291 additions and 163 deletions
+1 -1
View File
@@ -28,7 +28,7 @@ Everything is launched by `run_all.sh`, which auto-installs Go, creates the Pyth
- `!clear` - Clears pending title suggestions by marking them as posted, so they are excluded from future voting rounds; existing voting posts and votes are preserved
- `!mayhem` - Generates chaotic text using Ollama AI
- `!countvotes` - Reports current 👍 votes for the latest voting round, ranked most to fewest; repeat to refresh counts as people keep voting
- `!getvotes` - Posts current results from the voting server
- `!getvotes` - Reports current emoji results plus separately labeled web-vote results; an empty web ballot does not mean no emoji votes were cast
- `!voteurl` - Shares the voting URL where users can cast their votes
- **Persistent Storage**: Per-room SQLite databases with duplicate prevention
- **Acknowledgment System**: Reacts with ✅ to confirm suggestion collection
Binary file not shown.
+15 -7
View File
@@ -1,12 +1,13 @@
#!/usr/bin/env python3
"""
Script to monitor Matrix chat for !getvotes command and post vote results.
Reads from voteServer/vote_summary.json and posts results ordered from least to most votes.
Reports current emoji votes and separately labeled web votes.
"""
import asyncio
import json
import os
from pathlib import Path
import sys
import time as _time
from room import Room
@@ -41,7 +42,7 @@ async def main():
print("!getvotes command detected, posting vote results...")
# Read and format vote results
vote_message = format_vote_results(room)
vote_message = await get_vote_results(room)
# Post to chat
await room.alert_post(vote_message)
@@ -141,17 +142,24 @@ async def wait_for_getvotes(room, since_ms):
return None
async def get_vote_results(room):
"""Report emoji and web votes separately; they are independent ballots."""
emoji_results = await room.count_votes()
web_results = format_vote_results(room)
return f"{emoji_results}\n\n{web_results}"
def format_vote_results(room):
"""Read votes from database and format results ordered from least to most votes."""
import re
# Generate database name based on room ID (same pattern as suggestions db)
safe = re.sub(r'[^a-zA-Z0-9_-]', '_', room.config.room_id)
vote_db = f"votes_{safe}.db"
vote_db = Path(__file__).resolve().parent / f"votes_{safe}.db"
# Check if database exists
if not os.path.exists(vote_db):
return "❌ No vote data available yet. The voting system may not have received any votes."
return "📊 No web-vote database available yet. Emoji votes are reported separately above."
try:
import dbutil
@@ -178,10 +186,10 @@ def format_vote_results(room):
conn.close()
if not results or total_votes == 0:
return "📊 No votes have been cast yet."
return "📊 No web votes have been cast yet. Emoji votes are reported separately above."
# Build the message
lines = ["📊 Vote Results (ordered from least to most votes):", ""]
lines = ["📊 Web Vote Results (ordered from least to most votes):", ""]
for submission, count, voters in results:
vote_word = "vote" if count == 1 else "votes"
@@ -203,7 +211,7 @@ def format_vote_results(room):
return "\n".join(lines)
except Exception as e:
return f"❌ Error reading vote data: {str(e)}"
return f"❌ Error reading web vote data: {str(e)}"
if __name__ == "__main__":
BIN
View File
Binary file not shown.
+16 -17
View File
@@ -1,17 +1,16 @@
2026/10/31 00:38:33 Serving room '!HXiyYVEZOMRtkyvarN:jupiterbroadcasting.com' under /random (db ../suggestions__HXiyYVEZOMRtkyvarN_jupiterbroadcasting_com.db)
2026/10/31 00:38:33 Skipping room !gJYEKNllaubNlNkFIj:jupiterbroadcasting.com: slug /random already in use by another config
2026/10/31 00:38:33 Skipping room !ajyOBbqoCIbBhEqNPU:matrix.org: slug /random already in use by another config
2026/10/31 00:38:33 jsonEndpoint starting on :9080
2026/10/31 00:38:33 Error querying most recent post: no such table: fetch_log
2026/10/31 00:38:33 Error querying users: no such table: users
2026/10/31 00:38:33 Loaded 0 submissions from database
2026/10/31 00:39:03 Loaded 19 submissions from database
2026/10/31 00:39:03 Loaded 216 users from database (most recent post: 1793423415)
2026/10/31 00:39:33 Loaded 19 submissions from database
2026/10/31 00:39:33 Loaded 216 users from database (most recent post: 1793423415)
2026/10/31 00:40:03 Loaded 19 submissions from database
2026/10/31 00:40:03 Loaded 216 users from database (most recent post: 1793423415)
2026/10/31 00:40:33 Loaded 3 submissions from database
2026/10/31 00:40:33 Loaded 216 users from database (most recent post: 1793423415)
2026/10/31 00:41:03 Loaded 3 submissions from database
2026/10/31 00:41:03 Loaded 216 users from database (most recent post: 1793423415)
2026/10/31 01:09:01 Serving room '!HXiyYVEZOMRtkyvarN:jupiterbroadcasting.com' under /random (db ../suggestions__HXiyYVEZOMRtkyvarN_jupiterbroadcasting_com.db)
2026/10/31 01:09:01 Skipping room !gJYEKNllaubNlNkFIj:jupiterbroadcasting.com: slug /random already in use by another config
2026/10/31 01:09:01 Skipping room !ajyOBbqoCIbBhEqNPU:matrix.org: slug /random already in use by another config
2026/10/31 01:09:01 jsonEndpoint starting on :9080
2026/10/31 01:09:01 Loaded 6 submissions from database
2026/10/31 01:09:01 Loaded 216 users from database (most recent post: 1793426081)
2026/10/31 01:09:31 Loaded 6 submissions from database
2026/10/31 01:09:31 Loaded 216 users from database (most recent post: 1793426081)
2026/10/31 01:10:01 Loaded 6 submissions from database
2026/10/31 01:10:01 Loaded 216 users from database (most recent post: 1793426081)
2026/10/31 01:10:31 Loaded 6 submissions from database
2026/10/31 01:10:31 Loaded 216 users from database (most recent post: 1793426081)
2026/10/31 01:11:01 Loaded 6 submissions from database
2026/10/31 01:11:01 Loaded 216 users from database (most recent post: 1793426081)
2026/10/31 01:11:31 Loaded 6 submissions from database
2026/10/31 01:11:31 Loaded 216 users from database (most recent post: 1793426081)
+31 -50
View File
@@ -1,52 +1,33 @@
Logged in!
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from rpodcast with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from adevries17 with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from Wes with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from Wes with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from chrislas with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from CeeBee_Eh with ✅
Acked suggestion from definitely not magbot in a trenchcoat with ✅
Acked suggestion from nomadicoder with ✅
Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425116
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425126
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425137
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425148
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425158
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425169
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425180
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425190
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425201
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Stored 20 suggestions in database.
Last run for this room was at UNIX timestamp 1793425212
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793425222
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 21 suggestions in database.
Last run for this room was at UNIX timestamp 1793425233
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 20 suggestions in database.
Last run for this room was at UNIX timestamp 1793425244
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 19 suggestions in database.
Last run for this room was at UNIX timestamp 1793425254
Last run for this room was at UNIX timestamp 1793426929
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426941
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426952
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426962
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426973
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426984
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793426994
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427005
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427015
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427026
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427037
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427047
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427058
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427068
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427079
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 22 suggestions in database.
Last run for this room was at UNIX timestamp 1793427090
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍
+18 -17
View File
@@ -1,32 +1,33 @@
Logged in!
Last run for this room was at UNIX timestamp 1785951982
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Acked suggestion from magnolia_mayhem 💀⃤ (Matrix Version) with ✅
Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425114
Last run for this room was at UNIX timestamp 1793426930
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425124
Last run for this room was at UNIX timestamp 1793426941
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425135
Last run for this room was at UNIX timestamp 1793426952
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425145
Last run for this room was at UNIX timestamp 1793426962
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425156
Last run for this room was at UNIX timestamp 1793426973
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425167
Last run for this room was at UNIX timestamp 1793426984
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425177
Last run for this room was at UNIX timestamp 1793426994
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425188
Last run for this room was at UNIX timestamp 1793427005
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425199
Last run for this room was at UNIX timestamp 1793427016
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425209
Last run for this room was at UNIX timestamp 1793427026
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425220
Last run for this room was at UNIX timestamp 1793427037
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425231
Last run for this room was at UNIX timestamp 1793427048
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425241
Last run for this room was at UNIX timestamp 1793427058
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793425252
Last run for this room was at UNIX timestamp 1793427069
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793427079
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 1 suggestions in database.
Last run for this room was at UNIX timestamp 1793427090
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍
+31 -29
View File
@@ -1,31 +1,33 @@
Logged in!
Last run for this room was at UNIX timestamp 1793424796
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425114
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425124
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425135
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425145
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425156
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425167
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425177
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425188
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425198
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425209
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425220
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425230
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425241
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 41 suggestions in database.
Last run for this room was at UNIX timestamp 1793425251
Last run for this room was at UNIX timestamp 1793426930
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426942
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426952
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426963
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426973
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426984
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793426995
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427005
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427016
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427026
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427037
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427048
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427058
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427069
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427080
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍Stored 25 suggestions in database.
Last run for this room was at UNIX timestamp 1793427090
Looked back on 100 messages...␍Looked back on 200 messages...␍Looked back on 300 messages...␍Looked back on 400 messages...␍
+16 -16
View File
@@ -1,16 +1,16 @@
2026/10/31 00:38:36 Vote server serving room '!HXiyYVEZOMRtkyvarN:jupiterbroadcasting.com' under /random (db ../votes__HXiyYVEZOMRtkyvarN_jupiterbroadcasting_com.db)
2026/10/31 00:38:36 Skipping room !gJYEKNllaubNlNkFIj:jupiterbroadcasting.com: slug /random already in use by another config
2026/10/31 00:38:36 Skipping room !ajyOBbqoCIbBhEqNPU:matrix.org: slug /random already in use by another config
2026/10/31 00:38:36 Vote server starting on :9081
2026/10/31 00:38:36 Fetched 0 users (most recent post: 0)
2026/10/31 00:38:36 Fetched 0 submissions
2026/10/31 00:39:06 Fetched 19 submissions
2026/10/31 00:39:06 Fetched 216 users (most recent post: 1793423415)
2026/10/31 00:39:36 Fetched 19 submissions
2026/10/31 00:39:36 Fetched 216 users (most recent post: 1793423415)
2026/10/31 00:40:06 Fetched 19 submissions
2026/10/31 00:40:06 Fetched 216 users (most recent post: 1793423415)
2026/10/31 00:40:36 Fetched 3 submissions
2026/10/31 00:40:36 Fetched 216 users (most recent post: 1793423415)
2026/10/31 00:41:06 Fetched 3 submissions
2026/10/31 00:41:06 Fetched 216 users (most recent post: 1793423415)
2026/10/31 01:09:04 Vote server serving room '!HXiyYVEZOMRtkyvarN:jupiterbroadcasting.com' under /random (db ../votes__HXiyYVEZOMRtkyvarN_jupiterbroadcasting_com.db)
2026/10/31 01:09:04 Skipping room !gJYEKNllaubNlNkFIj:jupiterbroadcasting.com: slug /random already in use by another config
2026/10/31 01:09:04 Skipping room !ajyOBbqoCIbBhEqNPU:matrix.org: slug /random already in use by another config
2026/10/31 01:09:04 Vote server starting on :9081
2026/10/31 01:09:04 Fetched 6 submissions
2026/10/31 01:09:04 Fetched 216 users (most recent post: 1793426081)
2026/10/31 01:09:34 Fetched 6 submissions
2026/10/31 01:09:34 Fetched 216 users (most recent post: 1793426081)
2026/10/31 01:10:04 Fetched 6 submissions
2026/10/31 01:10:04 Fetched 216 users (most recent post: 1793426081)
2026/10/31 01:10:34 Fetched 6 submissions
2026/10/31 01:10:34 Fetched 216 users (most recent post: 1793426081)
2026/10/31 01:11:04 Fetched 6 submissions
2026/10/31 01:11:04 Fetched 216 users (most recent post: 1793426081)
2026/10/31 01:11:34 Fetched 6 submissions
2026/10/31 01:11:34 Fetched 216 users (most recent post: 1793426081)
+39 -25
View File
@@ -11,6 +11,7 @@ import sqlite3
import re
import asyncio
from nio import AsyncClient, LoginResponse, MessageDirection, ProfileGetDisplayNameResponse, RoomMessageText, RoomMessagesResponse, RoomSendResponse, SyncResponse
from nio.api import RelationshipType
from post import Post
import requests
import dbutil
@@ -578,7 +579,6 @@ class Room:
"""Read current thumbs-up votes for the most recent voting round."""
assert self.client is not None
next_batch = None
all_events = []
suggestion_votes = {}
seen_tokens = set()
found_round = False
@@ -602,7 +602,6 @@ class Room:
and event.body.strip().startswith("Time to vote!")):
found_round = True
break
all_events.append(event)
if isinstance(event, RoomMessageText) and event.sender == self.user_id:
match = re.match(r"^Suggestion (\d+):\s*(.*)", event.body, re.DOTALL)
event_id = getattr(event, "event_id", None)
@@ -622,29 +621,35 @@ class Room:
if not suggestion_votes:
return "No suggestion posts found for the latest voting round."
# matrix-nio stores the original Matrix event in source. Redactions can
# name their target at the top level or inside content (room v11+).
redacted = set()
for event in all_events:
source = getattr(event, "source", {})
if source.get("type") == "m.room.redaction":
target = source.get("redacts") or source.get("content", {}).get("redacts")
redacted.add(target)
for event in all_events:
source = getattr(event, "source", {})
content = source.get("content", {})
if (source.get("type") != "m.reaction"
or getattr(event, "event_id", None) in redacted
or source.get("unsigned", {}).get("redacted_because")):
continue
relation = content.get("m.relates_to", {})
if relation.get("rel_type") != "m.annotation" or relation.get("key") != "👍":
continue
target = suggestion_votes.get(relation.get("event_id"))
sender = getattr(event, "sender", None)
if target is not None and sender and sender != self.user_id:
target["voters"].add(sender)
# Fetch the live relations for each suggestion rather than assuming
# reactions are included in the room-history pages used above.
try:
for event_id, data in suggestion_votes.items():
async for event in self.client.room_get_event_relations(
self.config.room_id,
event_id,
rel_type=RelationshipType.annotation,
event_type="m.reaction",
limit=self.config.batch_size,
):
source = getattr(event, "source", {})
if source.get("unsigned", {}).get("redacted_because"):
continue
relation = source.get("content", {}).get("m.relates_to", {})
key = relation.get("key", "")
# Treat the usual presentation/skin-tone variants as the
# same thumbs-up vote that a user sees in their client.
key = key.replace("\ufe0f", "")
key = re.sub("[\U0001f3fb-\U0001f3ff]", "", key)
if (relation.get("rel_type") != "m.annotation"
or relation.get("event_id") != event_id or key != "👍"):
continue
sender = getattr(event, "sender", None)
if sender and sender != self.user_id:
data["voters"].add(sender)
except Exception as error:
print(f"Unable to fetch emoji voting reactions: {error}")
return "Unable to read emoji votes. Please try !countvotes again."
lines = ["Latest voting round — current emoji votes (most to fewest):"]
ranked = sorted(suggestion_votes.values(),
@@ -881,6 +886,15 @@ class Room:
May the odds be ever in your favor! 🏹🏹🏹
COMMANDS:
!suggest <title> — Submit a title suggestion.
!gettitles — Post pending suggestions for voting.
!countvotes — Show the latest round's current 👍 vote rankings.
!getvotes — Show emoji results and separate web-vote results.
!voteurl — Share this room's web voting link.
!clear — Clear pending suggestions from future voting rounds.
!mayhem — Generate chaotic text with Ollama AI.
NOTE: HTTP VOTING IS IN PRE-ALPHA. IF YOU WOULD LIKE TO SEE THE EARLY PRE-RELEASE, GO TO {self.vote_url()}
MAKE MAGBOT BETTER:
Binary file not shown.
+80 -1
View File
@@ -2,6 +2,8 @@ import unittest
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch
from nio import AsyncClient, RoomMessagesResponse
from nio.responses import RoomEventRelationsResponse
from room import Room
@@ -35,10 +37,48 @@ class CountVotesTests(unittest.IsolatedAsyncioTestCase):
self.enterContext(patch("room.RoomMessageText", Message))
self.enterContext(patch("room.RoomMessagesResponse", Response))
async def count(self, *pages):
async def count(self, *pages, live_reactions=None):
self.room.client.room_messages.side_effect = pages
events = [event for page in pages for event in getattr(page, "chunk", [])]
removed = set()
for event in events:
source = getattr(event, "source", {})
if source.get("type") == "m.room.redaction":
removed.add(source.get("redacts") or source.get("content", {}).get("redacts"))
async def relations(room_id, event_id, **kwargs):
for event in events if live_reactions is None else live_reactions:
relation = event.source.get("content", {}).get("m.relates_to", {})
if relation.get("event_id") == event_id and event.event_id not in removed:
yield event
self.room.client.room_get_event_relations = relations
return await self.room.count_votes()
async def test_votes_absent_from_timeline_are_read_from_live_relations(self):
result = await self.count(Response(chunk=[
message("Suggestion 1: Author: Title", "$one"),
message("Time to vote!", "$start"),
], end=None), live_reactions=[
reaction("$one", "alice", "$vote", key="👍🏽"),
reaction("$one", "bob", "$vote2", key="👍\ufe0f"),
])
self.assertIn("Suggestion 1: 2 votes", result)
async def test_relation_failure_is_not_reported_as_zero_votes(self):
async def broken_relations(*args, **kwargs):
raise RuntimeError("Server unavailable")
yield
self.room.client.room_messages.return_value = Response(chunk=[
message("Suggestion 1: Author: Title", "$one"),
message("Time to vote!", "$start"),
], end=None)
self.room.client.room_get_event_relations = broken_relations
result = await self.room.count_votes()
self.assertIn("Unable to read emoji votes", result)
self.assertNotIn("0 votes", result)
async def test_latest_round_ranking_and_later_votes_refresh(self):
latest = [
reaction("$two", "alice", "$v2"),
@@ -100,5 +140,44 @@ class CountVotesTests(unittest.IsolatedAsyncioTestCase):
self.assertIn("No suggestion posts found", await self.count(Response(chunk=[], end=None)))
class MatrixSDKVotesTests(unittest.IsolatedAsyncioTestCase):
async def test_real_sdk_parses_and_paginates_live_reactions(self):
room = Room.__new__(Room)
room.config = SimpleNamespace(room_id="!room:matrix.test", batch_size=2)
room.user_id = "@bot:matrix.test"
room.client = AsyncClient("https://matrix.test", room.user_id)
room.client.access_token = "test-token"
self.addAsyncCleanup(room.client.close)
def event(event_id, sender, event_type, content):
return {"event_id": event_id, "sender": sender, "type": event_type,
"origin_server_ts": 100000, "content": content,
"room_id": room.config.room_id}
history = RoomMessagesResponse.from_dict({
"start": "now", "chunk": [
event("$one", room.user_id, "m.room.message", {
"msgtype": "m.text", "body": "Suggestion 1: Author: Title"}),
event("$start", room.user_id, "m.room.message", {
"msgtype": "m.text", "body": "Time to vote!"}),
],
}, room.config.room_id)
def votes(sender, event_id, next_batch=None):
return RoomEventRelationsResponse.from_dict({
"chunk": [event(event_id, sender, "m.reaction", {"m.relates_to": {
"rel_type": "m.annotation", "key": "👍", "event_id": "$one",
}})], **({"next_batch": next_batch} if next_batch else {}),
}, room.config.room_id, "$one")
room.client._send = AsyncMock(side_effect=[
history, votes("@alice:matrix.test", "$v1", "page2"),
votes("@bob:matrix.test", "$v2"),
])
result = await room.count_votes()
self.assertIn("Suggestion 1: 2 votes", result)
self.assertIn("from=page2", room.client._send.await_args_list[-1].args[2])
if __name__ == "__main__":
unittest.main()
+44
View File
@@ -0,0 +1,44 @@
from contextlib import closing
from pathlib import Path
import sqlite3
import tempfile
from types import SimpleNamespace
import unittest
from unittest.mock import AsyncMock, patch
import get_votes
class GetVotesTests(unittest.IsolatedAsyncioTestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.root = Path(self.temp.name)
self.enterContext(patch("get_votes.__file__", str(self.root / "get_votes.py")))
self.room = SimpleNamespace(
config=SimpleNamespace(room_id="!test:matrix.org"),
count_votes=AsyncMock(return_value="Suggestion 1: 3 votes"),
)
with closing(sqlite3.connect(self.root / "votes__test_matrix_org.db")) as conn, conn:
conn.execute("CREATE TABLE votes (selected_submission TEXT, voter_display_name TEXT)")
async def test_emoji_votes_are_reported_when_web_database_is_empty(self):
result = await get_votes.get_vote_results(self.room)
self.assertIn("Suggestion 1: 3 votes", result)
self.assertIn("No web votes have been cast yet", result)
self.assertNotIn("No votes have been cast yet", result)
async def test_web_and_emoji_votes_have_separate_totals(self):
with closing(sqlite3.connect(self.root / "votes__test_matrix_org.db")) as conn, conn:
conn.execute("INSERT INTO votes VALUES ('Web title', 'alice')")
result = await get_votes.get_vote_results(self.room)
self.assertIn("Suggestion 1: 3 votes", result)
self.assertIn("Web Vote Results", result)
self.assertIn("Web title: 1 vote", result)
async def test_missing_web_database_does_not_hide_emoji_votes(self):
self.room.config.room_id = "!other:matrix.org"
result = await get_votes.get_vote_results(self.room)
self.assertIn("Suggestion 1: 3 votes", result)
self.assertIn("No web-vote database", result)
self.assertFalse((self.root / "votes__other_matrix_org.db").exists())
Binary file not shown.
Binary file not shown.
Binary file not shown.