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#)
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˜!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ÚrowÚcolss& rrÚUserListManager.init_user_dbä~Š~˜dŸl™lÓØ K‰K‹MˆØ ‰ ð  ô
ð
‰ Ð-Ø"#§*¡*¤,Ó/¡,˜3A—¡,ˆÐ ˜
I‰IÐ  Ô
I‰IÐ 
‰ ð ô
ð
‰ Ð1Ø"#§*¡*¤,Ó/¡,˜3A—¡,ˆÐ  TÔ
I‰IÐ 
Š
2026-08-12 17:14:01 -05:00
Ø
2026-09-04 10:21:24 -05:00
2026-08-06 21:34:52 -05:00
Ž ùò/0ùò$0s Á%D/ÃD4cƒ ó("VPP4GRjxL
2026-09-04 10:21:24 -05:00
'g\R4.#VPPfQhVPPP VPP
P R7GRjxL
p\V\4'g\RV 24VPPPPVPP
P4pV'g/\RVPP
2026-08-06 21:34:52 -05:00
P 24.#\R4VP4GRjxL
2026-09-04 10:21:24 -05:00
wr4p.pVPF}pVPPV4GRjxL
pVPRVRVR \!\"P"!44R
VPV^4R VPV^4/4K W`n
WPnV#EELrLu5i) 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× Ð ˆIðy‰y×ÑÒŸ)™)×*×/¸¿ ¹ ×8HÑ8H×8UÑ8UÐV×Vˆ ܘ)¤\× M ) Ð —99×)×-¨d¯i©i×.>Ñ.>×.FÑ.FÓGˆßÜ Ð¯©×)9Ñ)9×)AÑ)AÐ(BÐ ˆ ÐDØ=A×=RÑ=RÓ=T×7TÑ4ˆ Ð$4àˆØ—~”~ˆGØ!%§¡×!;Ñ!;¸GÓ!D×DˆLØ L‰Lؘ7Ø  ØœS¤§¢£Ó˜[Ÿ_™_¨W°aÓ˜}׸!Ó ö
ñŒ
Ø 0ÔØˆ òC Wñ8UñEùsTH H¡ H«A.HÂH ÂA<HÄA HÅ#HÅ$6HÆHÆA.HÈ HÈHÈHcƒ ó¼"/p/p^pVPPPpVPPPpRp^pVPPfQhWu8EdBVPPP VPPP VVR7GRjxL
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#\"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_postspéàˆ Øˆ
2026-08-06 21:34:52 -05:00
ØÐØ—Y‘Y×
2026-09-04 10:21:24 -05:00
ØŸ×Øˆ
؈ðy‰y×ÑÒÕ!
2026-08-06 21:34:52 -05:00
Ø!%§¡×!1Ñ!1×!?Ñ!?Ø ŸI™I×,×"@ó"÷ô " (Ô,@×ÏÏÈØàœ3˜xŸ~™~Ó.à%Ÿ^œ^! ×9Ø!&§¡˜Ø.9¯o©o¸fÀaÓ.HÈ1Õ.L˜ Ñ&)¨×)?Ñ)?À4Õ)GÓ%H˜
Ø6¸*ÐU[ÕG\Ô:\Ø4>¨&Ñ8Ø/9Ò&Ÿ\™\
2026-09-04 10:21:24 -05:00
÷" WÔ%>Øò&?ðÐ+;Ð;ñEøô<ô
ÜÐ1°!°Ðûð
2026-08-06 21:34:52 -05:00
üsbA,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!
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…àzzˆzÜ Ð ä~Š~˜dŸl™lÓØ K‰K‹Mˆäœ4Ÿ9š9›;Ó à—J”Jˆ
Ø— ‘ ð ð˜•OØ˜Õ˜Õ Ø˜Õ—H‘H˜]¨AÓ
öñõF ‰ ð ðœC §
¡
O¨X¯\©\«^×-EÑ-EÓ-GÌÐQUÐWiÐklÓImÐ
 pô
2026-08-06 21:34:52 -05:00

2026-09-04 10:21:24 -05:00
Š