-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.py
95 lines (78 loc) · 3.92 KB
/
database.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
92
93
94
95
from dotenv import load_dotenv
load_dotenv()
from app import app, db
from app.models import User, Bot, Rule
# from sqlalchemy import String, Integer, Date
# from alembic import op
# print(db)
ruleString1 = """{
"trigger": {
"type": "message",
"usesPrefix": true,
"details": {
"string": "hi"
}
},
"response": [{
"type": "message",
"details": {
"string": "hi there!"
}
}, {
"type": "emoji",
"details": {
"string": "Appacademylogo"
}
}]
}"""
ruleString2 = """{ "trigger": { "type": "message", "usesPrefix": true, "details": { "string": "bye" } }, "response": [{ "type": "message", "details": { "string": "goodbye friend!" } }] }"""
ruleString3 = """{ "trigger": { "type": "guildMemberAdd", "usesPrefix": false, "details": {"string": "noob" } }, "response": [{ "type": "addRole", "details": { "string": "noob" } }] }"""
ruleString4 = """{ "trigger": { "type": "message", "usesPrefix": true, "details": {"string": "addRole" } }, "response": [{ "type": "assignRole", "details": { "string": "" } }] }"""
ruleString5 = """{ "trigger": { "type": "guildMemberRemove", "usesPrefix": false, "details": { "string": "general" } }, "response": [{ "type": "message", "details": { "string": "user has left the server" } }] }"""
ruleString6 = """{ "trigger": { "type": "guildMemberAdd", "usesPrefix": false, "details": { "string": "Student" } }, "response": [{ "type": "addRole", "details": { "string": "Student" } }] }"""
ruleString7 = """{ "trigger": { "type": "message", "usesPrefix": false, "details": { "string": "cowabunga"} }, "response": [{ "type": "ban", "details": { "string": "" } }] }"""
# op.bulk_insert('users', [
# {'username'}
# ])
with app.app_context():
db.drop_all()
db.create_all()
user1 = User(username="anassri", email="fake@email.com", password="demopassword")
user2 = User(username="ivanhroth", email="fake2@email.com", password="demopassword2")
user3 = User(username="Cthulhuhub", email="fake3@email.com", password="demopassword3")
user4 = User(username="matt-ramotar", email="fake4@email.com", password="demopassword4")
bot1 = Bot(user_id=1, name="fakebot1", prefix="!", description="The first fake bot ever here", is_draft=False)
bot2 = Bot(user_id=2, name="fakebot2", prefix= "@", description="The second fake bot ever here", is_draft=False)
bot3 = Bot(user_id=3, name="fakebot3", prefix="#", description="The third fake bot ever here", is_draft=False)
bot4 = Bot(user_id=4, name="fakebot4", prefix="//", description="The fourth fake bot ever here", is_draft=False)
bot5 = Bot(user_id=1, name="fakebot5", prefix= "%", description="The fifth fake bot ever here", is_draft=True)
bot6 = Bot(user_id=1, name="fakebot6", prefix= "%", description="The fifth fake bot ever here", is_draft=False)
bot7 = Bot(user_id=1, name="fakebot7", prefix= "%", description="The fifth fake bot ever here", is_draft=False)
bot8 = Bot(user_id=1, name="fakebot8", prefix= "%", description="The fifth fake bot ever here", is_draft=False)
rule1 = Rule(bot_id=1, content=ruleString1)
rule2 = Rule(bot_id=2, content=ruleString2)
rule3 = Rule(bot_id=1, content=ruleString3)
rule4 = Rule(bot_id=4, content=ruleString5)
rule5 = Rule(bot_id=4, content=ruleString6)
rule6 = Rule(bot_id=6, content=ruleString6)
rule7 = Rule(bot_id=1, content=ruleString7)
db.session.add(user1)
db.session.add(user2)
db.session.add(user3)
db.session.add(user4)
db.session.add(bot1)
db.session.add(bot2)
db.session.add(bot3)
db.session.add(bot4)
db.session.add(bot5)
db.session.add(bot6)
db.session.add(bot7)
db.session.add(bot8)
db.session.add(rule1)
db.session.add(rule2)
db.session.add(rule3)
db.session.add(rule4)
db.session.add(rule5)
db.session.add(rule6)
db.session.add(rule7)
db.session.commit()