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

111 lines
14 KiB
Plaintext
Raw Normal View History

2026-08-06 21:34:52 -05:00
+
2026-09-04 10:21:24 -05:00
aàšj,ãóÄ€Rt^RIt^RIt^RIt^RIt^RIt^RIt^RIHtH t H
2026-08-12 17:14:01 -05:00
t
2026-09-04 10:21:24 -05:00
H t H t ^RI
2026-08-06 21:34:52 -05:00
Ht^RIt!RR4tRt]R8Xd]P&!]!44R#R#)z§
Python script that reads configs/config.yaml and scrapes a list of active users from the Matrix room.
2026-09-04 10:21:24 -05:00
Stores the user list in a SQLite database named after the room.
2026-08-06 21:34:52 -05:00
N)Ú AsyncClientÚ
2026-09-04 10:21:24 -05:00
LoginResponseÚRoomMessageTextÚRoomMessagesResponseÚ SyncResponse)ÚRoomcóXa€]tRt^toRtR RltRtRtRtRt Rt
Rt R t R
t
2026-08-06 21:34:52 -05:00
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&&Ú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 ór€\P!VP4pVP4pVP R4VP R4VP 4Uu.uF q3^,NK
ppRV9dVP R4RV9dVP R4VP R4VP R4VP 4Uu.uF q3^,NK
ppR V9dVP R
4\P !V4VP4R #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)
)
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-09-04 10:21:24 -05:00
CREATE TABLE IF NOT EXISTS fetch_log (
2026-08-06 21:34:52 -05:00
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp INTEGER,
2026-09-04 10:21:24 -05:00
user_count INTEGER,
2026-08-06 21:34:52 -05:00
datetime TEXT,
2026-09-04 10:21:24 -05:00
most_recent_post INTEGER DEFAULT 0
)
zPRAGMA table_info(fetch_log)Úmost_recent_postzCALTER TABLE fetch_log ADD COLUMN most_recent_post INTEGER DEFAULT 0N)ÚdbutilÚconnectrÚcursorÚexecuteÚfetchallÚcommitÚclose)rÚconnÚcÚrowÚcolss& rrÚUserListManager.init_user_dbsû€ä�~Š~˜dŸl™lÓ+ˆØ �K‰K‹MˆØ � ‰ ð  ô
ð
� ‰ Ð,Ô-Ø"#§*¡*¤,Ó/¡,˜3�A—�¡,ˆÐ/Ø ˜dÔ "Ø
�I‰IÐPÔ QØ  Ô $Ø
�I‰IÐRÔ Sð
� ‰ ð ô
ð
� ‰ Ð0Ô1Ø"#§*¡*¤,Ó/¡,˜3�A—�¡,ˆÐ/Ø  TÔ )Ø
�I‰IÐ[Ô \ä�
Š
2026-08-12 17:14:01 -05:00
�dÔØ �
2026-09-04 10:21:24 -05:00
‰
2026-08-06 21:34:52 -05:00
Ž ùò/0ùò$0s Á%D/ÃD4cƒ ó("€VPP4GRjx€L
2026-09-04 10:21:24 -05:00
'g\R4.#VPPfQhVPPP VPP
P R7GRjx€L
p\V\4'g\RV 24VPPPPVPP
P4pV'g/\RVPP
2026-08-06 21:34:52 -05:00
P 24.#\R4VP4GRjx€L
2026-09-04 10:21:24 -05:00
wr4p.pVPF}pVPPV4GRjx€L
pVPRVRVR \!\"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 Matrix)Ú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_seenr r!)r Úlogin_to_matrixÚprintÚclientÚsyncrÚ sync_timeoutÚ
isinstancerÚroomsÚgetrÚcount_user_postsr Úget_display_nameÚappendÚintÚtimer") rÚ sync_respÚroom_objÚ post_countsÚ
last_activityr"r r1r2s & rÚget_room_membersÚ UserListManager.get_room_membersJs­é€ð—Y‘Y×.Ñ.Ó0×0Ö0Ü Ð-Ô .؈Ið�y‰y×ÑÒ+Ð+Ð+ØŸ)™)×*Ñ*×/Ñ/¸¿ ¹ ×8HÑ8H×8UÑ8UÐ/ÓV×Vˆ ܘ)¤\×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ÔØˆ òC1ò Wñ8UñEùsT‚H H¡ H«A.HÂH ÂA<HÄA HÅ#HÅ$6HÆHÆA.HÈ HÈHÈHcƒ ó¼"€/p/p^pVPPPpVPPPpRp^pVPPfQhWu8EdBVPPP VPPP VVR7GRjx€L
p\V\4'dVP'gMÉV\VP4,
pVPFp \V \4'gKV Pp
VPV
2026-09-04 10:21:24 -05:00
^4^,W&\V PR,4p W¢9gW²V
2026-08-06 21:34:52 -05:00
,8”dW²V
&W³8”gK}T pK� VP pV'dWu8¼dMEKHWV3#Lú \"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ÚlimitièzError fetching messages: )r rÚ
batch_sizeÚuser_lookback_limitr6Ú
room_messagesrr9rÚchunkÚlenrÚsenderr;r?Úserver_timestampÚendÚ Exceptionr5)
rrCrDr"rJÚlookback_limitÚ
next_batchÚfetchedÚresponseÚeventrOÚ
2026-09-04 10:21:24 -05:00
event_timeÚes
& rr<Ú UserListManager.count_user_postsps¥é€àˆ ؈
2026-08-06 21:34:52 -05:00
ØÐØ—Y‘Y×%Ñ%×0Ñ0ˆ
2026-09-04 10:21:24 -05:00
ØŸ™×)Ñ)×=Ñ=ˆØˆ
؈ð�y‰y×ÑÒ+Ð+Ð+ØÕ&ð!
2026-08-06 21:34:52 -05:00
Ø!%§¡×!1Ñ!1×!?Ñ!?Ø ŸI™I×,Ñ,×4Ñ4Ø$Ø$ð"@ó"÷�ô " (Ô,@×AÒAÈÏÏÈØàœ3˜xŸ~™~Ó.Õ.�à%Ÿ^œ^�EÜ! %¬×9Ô9Ø!&§¡˜Ø.9¯o©o¸fÀaÓ.HÈ1Õ.L˜ Ñ+ô&)¨×)?Ñ)?À4Õ)GÓ%H˜
Ø!Ô6¸*ÐU[ÕG\Ô:\Ø4>¨&Ñ1à%Ö8Ø/9Ò,ñ,ð&Ÿ\™\�
2026-09-04 10:21:24 -05:00
÷" WÔ%>Øò&?ðÐ+;Ð;Ð;ñEøô<ô
ÜÐ1°!°Ð5Ô6Ýûð
2026-08-06 21:34:52 -05:00
üsb‚A,GÁ/A F5Â8F3Â9+F5Ã%GÃ&>F5Ä)AF5Æ F5Æ%F5Æ+GÆ3F5Æ5 GÇGÇGÇGÇGc
2026-09-04 10:21:24 -05:00
 ó¦€VP'g\R4R#\P!VP4pVP 4p\
\P!44pVPFHpVPRVR,VR,VR,VVR,VPR^434KJ ^R
I H pVPR V\VP4VP4P4\!VR ^434\P"!V4VP%4\R
\VP4 RVP 24R# \PdJTPR TR,TR,TTR,TPR^4TR,34EKUi;i)z&Write collected users to the database.zNo users to write to databaseNa 
2026-08-06 21:34:52 -05:00
INSERT INTO users (user_id, display_name, last_seen, last_updated, num_posts, last_active)
VALUES (?, ?, ?, ?, ?, ?)
ON CONFLICT(user_id) DO UPDATE SET
display_name = excluded.display_name,
2026-09-04 10:21:24 -05:00
last_seen = excluded.last_seen,
last_updated = excluded.last_updated,
num_posts = excluded.num_posts,
last_active = excluded.last_active
r1r2r3r r!zÃ
UPDATE users
2026-08-06 21:34:52 -05:00
SET display_name = ?, last_seen = ?, last_updated = ?, num_posts = ?, last_active = ?
2026-09-04 10:21:24 -05:00
WHERE user_id = ?
)Údatetimez
2026-08-06 21:34:52 -05:00
INSERT INTO fetch_log (timestamp, user_count, datetime, most_recent_post)
2026-09-04 10:21:24 -05:00
VALUES (?, ?, ?, ?)
r"zWrote z
users to )r r5r#r$rr%r?r@r&r;Úsqlite3ÚIntegrityErrorr\rNÚ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Ù ä�~Š~˜dŸl™lÓ+ˆØ �K‰K‹Mˆäœ4Ÿ9š9›;Ó'ˆ à—J”JˆDð
Ø— ‘ ð ð˜•OؘÕ(ؘÕ%Ø Ø˜Õ%Ø—H‘H˜]¨AÓ.ð
öñõF &Ø � ‰ ð ðœC §
¡
›O¨X¯\©\«^×-EÑ-EÓ-GÌÐQUÐWiÐklÓImÐ
nô pô
2026-08-06 21:34:52 -05:00
�
2026-09-04 10:21:24 -05:00
Š