13 lines
672 B
Python
13 lines
672 B
Python
#!/usr/bin/env python3
|
|
import sqlite3, pathlib, os
|
|
root=pathlib.Path(os.environ.get('AIOS_WEBOPS_ROOT','.')); db=root/'data'/'webops.sqlite3'
|
|
def send_owner_wechat(event_type,payload): print('[OWNER_WECHAT_NOTIFY]',event_type,payload)
|
|
with sqlite3.connect(db) as con:
|
|
con.row_factory=sqlite3.Row
|
|
rs=con.execute("SELECT * FROM owner_notifications WHERE status='queued' ORDER BY created_at LIMIT 20").fetchall()
|
|
for r in rs:
|
|
send_owner_wechat(r['event_type'],r['payload'])
|
|
con.execute("UPDATE owner_notifications SET status='sent',sent_at=datetime('now') WHERE id=?",(r['id'],))
|
|
con.commit()
|
|
print('OWNER_WECHAT_NOTIFY_WORKER_DONE', len(rs))
|