forked from TheRealRhyle/TwitchBot_full_rebuild
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.py
77 lines (66 loc) · 2.59 KB
/
loader.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
import os
import sqlite3
import installer
def loaddb():
conn = sqlite3.connect("dxchatbot.db")
c = conn.cursor()
return conn, c
def closedb():
conn.close()
def loading_seq():
# Check if db file exists first
if os.path.isfile('dxchatbot.db'):
print('Database file exists')
conn, c = loaddb()
else:
botnick = ''
create = input('No database file currently exists would you like to create one? ').lower()
if create == 'y' or create == 'yes':
chathost = input("Enter the chat host(irc.twitch.tv): ").lower()
botnick = input("Enter your bots name: ").lower()
while botnick == '':
botnick = input("You must provide your bots name: ").lower()
port = input("Enter the port, leave blank if unsure: ")
pwd = input("Enter your bots oauth token: ")
while pwd == '':
pwd = input("You must provide your bots oauth token: ")
if chathost == "":
chathost = 'irc.twitch.tv'
if port == '':
port = 6667
if 'oauth:' in pwd:
print('Thank you, initializing database.')
else:
pwd = 'oauth:' + pwd
installer.installbot(chathost, botnick, port, pwd)
conn = sqlite3.connect("dxchatbot.db")
c = conn.cursor()
lst = c.execute("select * from streamer").fetchall()
varsx = ['chathost', 'botnick', 'port', 'pwd','readbuffer']
lst = list(lst[0])
dictaf = dict(zip(varsx, lst))
print('Database initialized for {}.'.format(dictaf['botnick']))
return conn, c
if __name__ == '__main__':
conn, c = loading_seq()
reintall_test = input('Do you want to reinitialize the database with different values? ')
if reintall_test == 'yes':
chathost = input("Enter the chat host(irc.twitch.tv): ").lower()
botnick = input("Enter your bots name: ").lower()
while botnick == '':
botnick = input("You must provide your bots name: ").lower()
port = input("Enter the port, leave blank if unsure: ")
pwd = input("Enter your bots oauth token: ")
while pwd == '':
pwd = input("You must provide your bots oauth token: ")
if chathost == "":
chathost = 'irc.twitch.tv'
if port == '':
port = 6667
if 'oauth:' in pwd:
print('Thank you, initializing database.')
else:
print('Thank you, initializing database.')
pwd = 'oauth:' + pwd
installer.reinstall(chathost, botnick, port, pwd)
closedb()