-
Notifications
You must be signed in to change notification settings - Fork 1
/
playerDatabase.py
91 lines (75 loc) · 2.81 KB
/
playerDatabase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import sqlite3
import discord
import inspect
import os.path
# if the table isnt created then create it and need only be ran once
def create_player_table():
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
print("DB Path :" + path)
conn = sqlite3.connect(path + '/TheWatcher.db')
c = conn.cursor()
c.execute(
'CREATE TABLE IF NOT EXISTS playerNameChange(playerID INTEGER, originalName TEXT, newName TEXT)')
conn.commit()
c.close()
conn.close()
# add dynamic data to the player table
def add_player_data(playerID, originalName, newName):
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
print("DB Path :" + path)
conn = sqlite3.connect(path + '/TheWatcher.db')
c = conn.cursor()
c.execute("INSERT INTO playerNameChange (playerID, originalName, newName) VALUES (?, ?, ?)",
(playerID, originalName, newName))
conn.commit()
c.close()
conn.close()
# add dynamic data to the player table
def update_player_name(playerID, newName):
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
print("DB Path :" + path)
conn = sqlite3.connect(path + '/TheWatcher.db')
c = conn.cursor()
c.execute("UPDATE playerNameChange SET newName =? WHERE playerID = ?",
(newName, playerID))
conn.commit()
c.close()
conn.close()
def read_existing_player_data():
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
print("DB Path :" + path)
conn = sqlite3.connect(path + '/TheWatcher.db')
c = conn.cursor()
players = []
players = c.execute("SELECT * FROM playerNameChange").fetchall()
conn.commit()
c.close()
conn.close()
return players
def check_for_existing_player(playerid):
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
print("DB Path :" + path)
conn = sqlite3.connect(path + '/TheWatcher.db')
c = conn.cursor()
players = []
players = c.execute(
"SELECT playerID, originalName, newName FROM playerNameChange WHERE playerID =?", (playerid,)).fetchall()
conn.commit()
c.close()
conn.close()
return players
def get_DB_linked_player_Embed_List():
newList = []
playerList = read_existing_player_data()
for p in playerList:
embed = discord.Embed(title=str(p[1]),
url=f"https://steamcommunity.com/profiles/" +
str(p[0]),
description='Current Name=' + str(p[2]))
newList.append(embed)
return newList