39 lines
1.7 KiB
Python
Executable File
39 lines
1.7 KiB
Python
Executable File
from settings import get_kbans
|
|
import vdf
|
|
|
|
def main():
|
|
with get_kbans() as conn:
|
|
with conn.cursor(buffered=True) as cur:
|
|
t = {}
|
|
with open("banlist.cfg", encoding="utf-8") as f:
|
|
t = vdf.load(f)["banlist"]
|
|
for key, val in t.items():
|
|
sql_statement = """
|
|
INSERT INTO knifeban_web.KbRestrict_CurrentBans
|
|
(client_name, client_steamid, client_ip, admin_name, admin_steamid, reason, `map`, `length`,
|
|
time_stamp_start, time_played_start, time_played_end, is_expired, is_removed, time_stamp_removed,
|
|
admin_name_removed, admin_steamid_removed, reason_removed)
|
|
VALUES('unknown name', %s, 'unknown ip', %s, 'unknown steamID', 'knifebanned', 'unknown map', %s, current_timestamp(), %s, %s, %s, 0, 0, '', '', '');
|
|
"""
|
|
admin_name = 'unknown admin'
|
|
if 'admin' in val: admin_name = val['admin']
|
|
length = 1
|
|
if 'duration' in val:
|
|
length = int(val['duration'])
|
|
is_expired = 0
|
|
|
|
#length 0 means permanent on the webproject but in sourcemod its just saying expired.
|
|
if length == 0:
|
|
is_expired = 1
|
|
length = 1
|
|
elif length == -1: length = 0
|
|
time_hour = int(val['time']) / 60
|
|
time_minutes = int(val['time']) & 60
|
|
time_played_start = time_hour + time_minutes
|
|
cur.execute(sql_statement, [key, admin_name, length, time_played_start, time_played_start + length, is_expired])
|
|
#print(sql_statement)
|
|
conn.commit()
|
|
|
|
if __name__ == '__main__':
|
|
main()
|