Commits

Ada Young committed 9d61c6f

Now we can do logdb:amblog!! There's no searching yet but anyway!

  • Participants
  • Parent commits 3f88c12

Comments (0)

Files changed (1)

 
 <aliases>
   <alias
-   match="^LogDB:readlog (.+?)( \d+)?( \d+)?$"
+   match="^LogDB:(read|amb)log (.+?)( \d+)?( \d+)?$"
    enabled="y"
    regexp="y"
    send_to="12"
    sequence="100"
   >
   <send>
-if len("%2") > 0 and len("%3") > 0:
-    ShowLog("%1", int("%2"), int("%3"))
-elif len("%2") > 0:
-    ShowLog("%1", int("%2"))
+log_type = "%1".lower()
+if len("%3") > 0 and len("%4") > 0:
+    ShowLog(log_type, "%2", int("%3"), int("%4"))
+elif len("%3") > 0:
+    ShowLog(log_type, "%2", int("%3"))
 else:
-    ShowLog("%1")
+    ShowLog(log_type, "%2")
   </send>
   </alias>
   <alias
         return orgname
     return None
 
-def ShowLog(orgname, startfrom=None, fromdays=None):
+def ShowLog(log_type, orgname, startfrom=None, fromdays=None):
+    if log_type == "read":
+        log_type = "General"
+    elif log_type == "amb":
+        log_type = "Ambassadorial"
+
     if startfrom is None:
         startfrom = 0
     if fromdays is None:
     datefrom = datefrom.strftime("%Y-%m-%d %H:%M:%S")
     dateto = dateto.strftime("%Y-%m-%d %H:%M:%S")
 
-    cursor.execute("SELECT timestamp, message FROM org_logs l join orgs o on l.orgid=o.id WHERE o.orgname=? AND l.timestamp>=datetime(?) AND l.timestamp<datetime(?) ORDER BY l.timestamp ASC", (orgname, datefrom, dateto))
+    cursor.execute("SELECT timestamp, message FROM org_logs l join orgs o on l.orgid=o.id WHERE o.orgname=? AND l.timestamp>=datetime(?) AND l.timestamp<datetime(?) AND l.log_type=? ORDER BY l.timestamp ASC", (orgname, datefrom, dateto, log_type))
     results = cursor.fetchall()
     Note("General log for %s: (%s)" % (orgname, cdate))
     for i in results[startfrom:]: