Files
titlebot-ng-ng/__pycache__/get_user_list.cpython-314.pyc
T

114 lines
14 KiB
Plaintext
Raw Normal View History

2026-08-06 21:34:52 -05:00
+
2026-08-12 17:14:01 -05:00
�î|j§+ãó¸€Rt^RIt^RIt^RIt^RIt^RIt^RIt^RIHtH t H
t
H t ^RI H
2026-08-06 21:34:52 -05:00
t
!RR4tRt]R8Xd]P"!]!44R#R#)z§
2026-08-12 17:14:01 -05:00
Python script that reads configs/config.yaml and scrapes a list of active users from the Matrix room.
2026-08-06 21:34:52 -05:00
Stores the user list in a SQLite database named after the room.
2026-08-12 17:14:01 -05:00
N)Ú AsyncClientÚ
LoginResponseÚRoomMessagesResponseÚ SyncResponse)ÚRoomcóXa€]tRt^toRtR RltRtRtRtRt Rt
Rt R t R
2026-08-06 21:34:52 -05:00
t
VtR #)
ÚUserListManagerz@Manages collection and storage of active users in a Matrix room.có~€\V4Vn.VnVP4VnVP 4R#)N)rÚroomÚusersÚget_user_db_pathÚdb_pathÚ init_user_db)ÚselfÚ config_paths&&Ú//home/nolan/dev/titlebot-ng-ng/get_user_list.pyÚ__init__ÚUserListManager.__init__s1€Ü˜Ó%ˆŒ ؈Œ
Ø×,Ñ,Ó.ˆŒ Ø ×ÑÖóc óz€\P!RRVPPP4pRV R2#)zFGenerate database path for user list, similar to suggestions database.z[^a-zA-Z0-9_-]Ú_Úusers_z.db)ÚreÚsubr
ÚconfigÚroom_id)rÚsafes& rr Ú UserListManager.get_user_db_paths4€ä�vŠvÐ'¨¨d¯i©i×.>Ñ.>×.FÑ.FÓGˆØ˜�v˜SÐ!Ð!rc óf€\P!VP4pVP4pVP R4VP R4VP 4Uu.uF q3^,NK
ppRV9dVP R4RV9dVP R4VP R4VP R4VP 4Uu.uF q3^,NK
ppR V9dVP R
4VP
4VP4R #uupiuupi) z"Initialize the user list database.a‰
CREATE TABLE IF NOT EXISTS users (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT UNIQUE,
display_name TEXT,
last_seen INTEGER,
last_updated INTEGER,
num_posts INTEGER DEFAULT 0,
last_active INTEGER DEFAULT 0,
UNIQUE(user_id)
)
2026-08-12 17:14:01 -05:00
zPRAGMA table_info(users)Ú num_postsz8ALTER TABLE users ADD COLUMN num_posts INTEGER DEFAULT 0Ú last_activez:ALTER TABLE users ADD COLUMN last_active INTEGER DEFAULT 0a
2026-08-06 21:34:52 -05:00
CREATE TABLE IF NOT EXISTS fetch_log (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp INTEGER,
user_count INTEGER,
2026-08-12 17:14:01 -05:00
datetime TEXT,
2026-08-06 21:34:52 -05:00
most_recent_post INTEGER DEFAULT 0
2026-08-12 17:14:01 -05:00
)
zPRAGMA table_info(fetch_log)Úmost_recent_postzCALTER TABLE fetch_log ADD COLUMN most_recent_post INTEGER DEFAULT 0N)Úsqlite3Úconnectr
ÚcursorÚexecuteÚfetchallÚcommitÚclose)rÚconnÚcÚrowÚcolss& rrÚUserListManager.init_user_dbsø€ä�Š˜tŸ|™|Ó,ˆØ �K‰K‹MˆØ � ‰ ð  ô
ð
� ‰ Ð,Ô-Ø"#§*¡*¤,Ó/¡,˜3�A—�¡,ˆÐ/Ø ˜dÔ "Ø
�I‰IÐPÔ QØ  Ô $Ø
�I‰IÐRÔ Sð
� ‰ ð ô
ð
� ‰ Ð0Ô1Ø"#§*¡*¤,Ó/¡,˜3�A—�¡,ˆÐ/Ø  TÔ )Ø
�I‰IÐ[Ô \à � ‰ Œ
2026-08-06 21:34:52 -05:00
Ø �
2026-08-12 17:14:01 -05:00
‰
Ž ùò/0ùò$0s Á%D)ÃD.cƒ ó¸"€VPP4GRjx€L
'g\R4.#VPPP RR7GRjx€L
p\ V\ 4'g\RV 24VPPPPVPPP4pV'g/\RVPPP 24.#\R4VP4GRjx€L
wr4p.pVPF}pVPPV4GRjx€L
2026-08-06 21:34:52 -05:00
pVPRVR VR
2026-08-12 17:14:01 -05:00
\\ P !44R VPV^4R VPV^4/4K W`n WPnV#EL°ELrLªLu5i)
z=Fetch all members from the Matrix room and count their posts.NzFailed to login to Matrixi¸ )Útimeoutz
2026-08-06 21:34:52 -05:00
Sync failed: zCould not find room z3Counting posts per user (this may take a moment)...Úuser_idÚ display_nameÚ last_seenrr )r
Úlogin_to_matrixÚprintÚclientÚsyncÚ
isinstancerÚroomsÚgetrrÚcount_user_postsr Úget_display_nameÚappendÚintÚtimer!) rÚ sync_respÚroom_objÚ post_countsÚ
last_activityr!r r0r1s & rÚget_room_membersÚ UserListManager.get_room_membersIs†é€ð—Y‘Y×.Ñ.Ó0×0Ö0Ü Ð-Ô .؈IðŸ)™)×*Ñ*×/Ñ/¸Ð/Ó=×=ˆ ܘ)¤\×2Ò2Ü �M ) Ð-Ô .ð—9‘9×#Ñ#×)Ñ)×-Ñ-¨d¯i©i×.>Ñ.>×.FÑ.FÓGˆßÜ Ð(¨¯©×)9Ñ)9×)AÑ)AÐ(BÐCÔ D؈Iô ÐCÔDØ=A×=RÑ=RÓ=T×7TÑ4ˆ Ð$4àˆØ—~”~ˆGØ!%§¡×!;Ñ!;¸GÓ!D×DˆLØ �L‰Lؘ7Ø  ØœS¤§¢£Ó-ؘ[Ÿ_™_¨W°aÓ8ؘ}×0Ñ0°¸!Ó<ð ö
ñ&ðŒ
Ø 0ÔØˆ òA1ò
>ñ8UñEùsS‚G G¡ G«6GÁ!GÁ"A<GÃA GÄ+GÄ,6GÅ"GÅ#A.GÇGÇGÇGcƒ óÒ"€/p/p^pVPPPpVPPPpRp^pWu8EdfVPPP VPPP VVR7GRjx€L
p\V\4'dVP'gMíV\VP4,
pVPF£p \V R4'gK\V R4'gK+V Pp
2026-08-12 17:14:01 -05:00
VPV
2026-08-06 21:34:52 -05:00
^4^,W&\V R4'gKf\V PR,4p W¢9gW²V
,8”dW²V
&W³8”gK¡T pK¥ VP pV'dWu8¼dMEKlWV3#EL \"dp \%RT 24Rp ? K&Rp ? ii;i5i)zMCount total number of posts by each user in the room and track last activity.N)rÚstartÚlimitÚsenderÚbodyÚserver_timestampièzError fetching messages: )r
rÚ
batch_sizeÚuser_lookback_limitr5Ú
room_messagesrr7rÚchunkÚlenÚhasattrrHr9r=rJÚendÚ Exceptionr4)
2026-08-12 17:14:01 -05:00
rrArBr!rKÚlookback_limitÚ
next_batchÚfetchedÚresponseÚeventrHÚ
2026-08-06 21:34:52 -05:00
event_timeÚes
& rr:Ú UserListManager.count_user_postsns©é€àˆ ؈
ØÐØ—Y‘Y×%Ñ%×0Ñ0ˆ
ØŸ™×)Ñ)×=Ñ=ˆØˆ
؈ðÕ&ð"
Ø!%§¡×!1Ñ!1×!?Ñ!?Ø ŸI™I×,Ñ,×4Ñ4Ø$Ø$ð"@ó"÷�ô " (Ô,@×AÒAÈÏÏÈØàœ3˜xŸ~™~Ó.Õ.�à%Ÿ^œ^�Eܘu h×/Ô/´G¸EÀ6×4JÔ4JØ!&§¡˜Ø.9¯o©o¸fÀaÓ.HÈ1Õ.L˜ Ñ+ô# 5Ð*<×=Ô=Ü),¨U×-CÑ-CÀtÕ-KÓ)L˜JØ%Ô:¸jÐY_ÕK`Ô>`Ø8B¨fÑ 5à)Ö<Ø3=Ò 0ñ,ð&Ÿ\™\�
÷" WÔ%>Øò&?ðÐ+;Ð;Ð;òGøô>ô
ÜÐ1°!°Ð5Ô6Ýûð
2026-08-12 17:14:01 -05:00
üsm‚AG'ÁA GÂF=Â+GÃ G'Ã :GÄ GÄ6GÅ6GÆGÆ/GÆ5G'Æ=GÇ G$Ç GÇG'ÇG$Ç$G'c
2026-08-06 21:34:52 -05:00
 óš€VP'g\R4R#\P!VP4pVP 4p\
2026-08-12 17:14:01 -05:00
\P!44pVPFHpVPRVR,VR,VR,VVR,VPR^434KJ ^R
I H pVPR V\VP4VP4P4\VR ^434VP!4VP#4\R
\VP4 RVP 24R# \PdJTPR TR,TR,TTR,TPR^4TR,34EKOi;i)z&Write collected users to the database.zNo users to write to databaseNa 
INSERT INTO users (user_id, display_name, last_seen, last_updated, num_posts, last_active)
VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(user_id) DO UPDATE SET
2026-08-06 21:34:52 -05:00
display_name = excluded.display_name,
last_seen = excluded.last_seen,
last_updated = excluded.last_updated,
num_posts = excluded.num_posts,
last_active = excluded.last_active
r0r1r2rr zÃ
UPDATE users
SET display_name = ?, last_seen = ?, last_updated = ?, num_posts = ?, last_active = ?
2026-08-12 17:14:01 -05:00
WHERE user_id = ?
2026-08-06 21:34:52 -05:00
)Údatetimez
2026-08-12 17:14:01 -05:00
INSERT INTO fetch_log (timestamp, user_count, datetime, most_recent_post)
VALUES (?, ?, ?, ?)
2026-08-06 21:34:52 -05:00
r!zWrote z
users to )r r4r"r#r
2026-08-12 17:14:01 -05:00
r$r=r>r%r9ÚIntegrityErrorr\rOÚnowÚ isoformatÚgetattrr'r()rr)r*Ú current_timeÚuserr\s& rÚwrite_users_to_dbÚ!UserListManager.write_users_to_db s‚€à�z�zˆzÜ Ð1Ô 2Ù ä�Š˜tŸ|™|Ó,ˆØ �K‰K‹Mˆäœ4Ÿ9š9›;Ó'ˆ à—J”JˆDð
2026-08-06 21:34:52 -05:00
Ø— ‘ ð ð˜•OؘÕ(ؘÕ%Ø Ø˜Õ%Ø—H‘H˜]¨AÓ.ð
öñõF &Ø � ‰ ð ðœC §
¡
›O¨X¯\©\«^×-EÑ-EÓ-GÌÐQUÐWiÐklÓImÐ
2026-08-12 17:14:01 -05:00
nô pð
2026-08-06 21:34:52 -05:00
� ‰ Œ
2026-08-12 17:14:01 -05:00
Ø �