Selaa lähdekoodia

투표 버그 수정 및 차단 해제 방식 변경

잉여개발기 (SPDV) 2 vuotta sitten
vanhempi
sitoutus
93cd8c30f5
2 muutettua tiedostoa jossa 14 lisäystä ja 20 poistoa
  1. 13 19
      route/tool/func.py
  2. 1 1
      route/vote_close.py

+ 13 - 19
route/tool/func.py

@@ -405,16 +405,22 @@ def back_up(data_db_set):
 
             back_time = 1
 
-        threading.Timer(
-            60 * 60 * back_time, 
-            back_up,
-            [data_db_set]
-        ).start()
+        threading.Timer(60 * 60 * back_time, back_up, [data_db_set]).start()
+
+def do_ban_end():
+    with get_db_connect() as conn:
+        curs = conn.cursor()
+
+        curs.execute(db_change("update rb set ongoing = '' where end < ? and end != '' and ongoing = '1'"), [get_time()])
+
+        threading.Timer(60, do_ban_end).start()
 
 def auto_do_something(data_db_set):
     if data_db_set['type'] == 'sqlite':
         back_up(data_db_set)
 
+    do_ban_end()
+
 def update(ver_num, set_data):
     with get_db_connect() as conn:
         curs = conn.cursor()
@@ -2100,15 +2106,7 @@ def ban_check(ip = None, tool = ''):
         if admin_check(None, None, ip) == 1:
             return 0
 
-        curs.execute(db_change(
-            "update rb set ongoing = '' " + \
-            "where end < ? and end != '' and ongoing = '1'"
-        ), [get_time()])
-
-        curs.execute(db_change("" + \
-            "select login, block from rb " + \
-            "where band = 'regex' and ongoing = '1'" + \
-        ""))
+        curs.execute(db_change("select login, block from rb where band = 'regex' and ongoing = '1'"))
         regex_d = curs.fetchall()
         for test_r in regex_d:
             g_regex = re.compile(test_r[1])
@@ -2119,11 +2117,7 @@ def ban_check(ip = None, tool = ''):
                 else:
                     return 1
 
-        curs.execute(db_change("" + \
-            "select login from rb " + \
-            "where block = ? and band = '' and ongoing = '1'" + \
-            "" + \
-        ""), [ip])
+        curs.execute(db_change("select login from rb where block = ? and band = '' and ongoing = '1'"), [ip])
         ban_d = curs.fetchall()
         if ban_d:
             if tool == 'login':

+ 1 - 1
route/vote_close.py

@@ -23,7 +23,7 @@ def vote_close(num = 1):
         else:
             type_set = 'n_close'
 
-        curs.execute(db_change("update vote set type = ? where user = '' and id = ?"), [type_set, num])
+        curs.execute(db_change("update vote set type = ? where user = '' and id = ? and type = ?"), [type_set, num, data_list[0][0]])
         conn.commit()
 
         if data_list[0][0] == 'close' or data_list[0][0] == 'n_close':