-
Notifications
You must be signed in to change notification settings - Fork 0
/
format.py
182 lines (156 loc) · 7.82 KB
/
format.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import json
from datetime import datetime
books_edit = [["genesis", 50, 1533], ["exodus", 40, 1213], ["leviticus", 27, 859], ["numbers", 36, 1288], ["deuteronomy", 34, 959], ["joshua", 24, 658], ["judges", 21, 618],
["ruth", 4, 85], ["1 samuel", 31, 810],
["2 samuel", 24, 695], ["1 kings", 22, 816], ["2 kings", 25, 719], ["1 chronicles", 29, 942], ["2 chronicles", 36, 822], ["ezra", 10, 280], ["nehemiah", 13, 406], ["esther", 10, 167],
["job", 42, 1070], ["psalms", 150, 2461], ["proverbs", 31, 915], ["ecclesiastes", 12, 222], ["song of songs", 8, 117], ["isaiah", 66, 1292], ["jeremiah", 52, 1364], ["lamentations", 5, 154],
["ezekiel", 48, 1273], ["daniel", 12, 357], ["hosea", 14, 197], ["joel", 3, 73], ["amos", 9, 146], ["obadiah", 1, 21], ["jonah", 4, 48], ["micah", 7, 105], ["nahum", 3, 47], ["habakkuk", 3, 56],
["zephaniah", 3, 53], ["haggai", 2, 38], ["zechariah", 14, 211], ["malachi", 4, 55], ["matthew", 28, 1071], ["mark", 16, 678], ["luke", 24, 1151], ["john", 21, 879], ["acts", 28, 1007], ["romans", 16, 433],
["1 corinthians", 16, 437], ["2 corinthians", 13, 257], ["galatians", 6, 149], ["ephesians", 6, 155], ["philippians", 4, 104], ["colossians", 4, 95], ["1 thessalonians", 5, 89],
["2 thessalonians", 3, 47], ["1 timothy", 6, 113], ["2 timothy", 4, 83], ["titus", 3, 46], ["philemon", 1, 25], ["hebrews", 13, 303], ["james", 5, 108], ["1 peter", 5, 105],
["2 peter", 3, 61], ["1 john", 5, 105], ["2 john", 1, 13], ["3 john", 1, 14], ["jude", 1, 25], ["revelation", 22, 404]]
books = ["genesis", "exodus", "leviticus", "numbers", "deuteronomy", "joshua", "judges", "ruth", "1 samuel",
"2 samuel", "1 kings", "2 kings", "1 chronicles", "2 chronicles", "ezra", "nehemiah", "esther",
"job", "psalms", "proverbs", "ecclesiastes", "song of songs", "isaiah", "jeremiah", "lamentations",
"ezekiel", "daniel", "hosea", "joel", "amos", "obadiah", "jonah", "micah", "nahum", "habakkuk",
"zephaniah", "haggai", "zechariah", "malachi", "matthew", "mark", "luke", "john", "acts", "romans",
"1 corinthians", "2 corinthians", "galatians", "ephesians", "philippians", "colossians", "1 thessalonians",
"2 thessalonians", "1 timothy", "2 timothy", "titus", "philemon", "hebrews", "james", "1 peter",
"2 peter", "1 john", "2 john", "3 john", "jude", "revelation"]
apocrypha_books = ["tobit", "judith"]
translations = ["cherokee", "bbe", "kjv", "web", "oeb-cw", "webbe", "oeb-us", "clementine", "almeida", "rccv"]
translation_guild = []
def format_trans(translation, guild_id):
guild_id = str(guild_id)
f_read = open("translations.txt", "r")
lines = f_read.readlines()
f_read.close()
f_write = open("translations.txt", "a")
f_write.truncate(0)
for x in lines:
if guild_id not in x:
f_write.write(x)
f_write.close()
f_append = open("translations.txt", "a")
f_append.write(guild_id + " " + translation + "\n")
translation_guild.append([guild_id, translation])
f_append.close()
def format_scrip(scripture):
scripture = scripture.lower().replace(":", " ")
split_scripture = scripture.split()
book_string = split_scripture[0]
chapter = "1"
verse = ""
if len(split_scripture) >= 5:
return -1
if len(split_scripture) >= 2:
if len(split_scripture) == 4 or not split_scripture[1].strip("-").isnumeric():
if split_scripture[0].isnumeric():
book_string = split_scripture[1]
split_scripture[0] = split_scripture[0] + " " + split_scripture[1]
split_scripture.pop(1)
if len(split_scripture) >= 2:
chapter = split_scripture[1]
if len(split_scripture) >= 3:
verse = ":" + split_scripture[2]
verse_int = verse.replace(":", "").split("-")
if len(verse_int) > 1:
start = int(verse_int[0])
end = int(verse_int[1])
if end <= start:
verse = ":" + str(max(1, start))
book = book_string
if book_string.strip("-").isnumeric():
book = books[min(max(abs(int(book_string)), 1), 66) - 1]
books_with_substring = [string for string in books if book in string]
if len(books_with_substring) == 0:
return -2
else:
for b in books_edit:
if b[0] == books_with_substring[0]:
if int(chapter) > int(b[1]):
chapter = str(b[1])
break
scripture = books_with_substring[0].title() + " " + chapter.strip("-") + verse
return scripture
def scripture_link(scripture):
book = scripture.upper().replace(" ", "").replace("PHILIPPIANS", "PHP").replace("JUDGES", "JDG")[:3]
book = book.replace("SON", "SNG").replace("EZE", "EZK").replace("JOE", "JOL").replace("PHI", "PHM")
book = book.replace("NAH", "NAM").replace("MAR", "MRK").replace("JOH", "JHN").replace("JAM", "JAS")
book = book.replace("1JO", "1JN").replace("2JO", "2JN").replace("3JO", "3JN")
book_chapter = scripture[1:].split(":")[0]
chapter = ""
for c in book_chapter:
if c.isdigit():
chapter = chapter + c
return "https://bible.com/bible/1/" + book + "." + chapter
def book_icon(scripture):
scripture = scripture.lower()
book = [string for string in books if string in scripture][0]
if book == "1 samuel" or book == "2 samuel":
book = "samuel"
elif book == "1 kings" or book == "2 kings":
book = "kings"
elif book == "1 chronicles" or book == "2 chronicles":
book = "chronicles"
elif book == "song of songs":
book = "song of solomon"
elif book == "jonah":
book = "Jonah"
book = book.replace(" ", "-")
link = "https://overviewbible.com/wp-content/uploads/2014/06/" + book + "-free-bible-icon-150x150.png"
if book == "ruth" or book == "samuel" or book == "ezra" or book == "psalms" or book == "proverbs" or book == "philippians":
link = "https://overviewbible.com/wp-content/uploads/2014/06/" + book + "-free-bible-icon.png-150x150.png"
if book == "1-corinthians":
link = "https://overviewbible.com/wp-content/uploads/2014/06/" + book + "300x300-150x150.png"
return link
def get_guild_trans(guild_id):
translation = "kjv"
guild_id = str(guild_id)
for x in translation_guild:
if guild_id in x[0]:
translation = x[1]
return translation
def get_note(user_id, location):
with open("notes.json", "r") as file:
data = json.load(file)
try:
for d in data:
for key in d.keys():
if key == str(user_id):
for k in d[key]:
for lo in k.keys():
if lo == location:
return " __*Your note: \"" + k[location] + "\"*__ "
return " "
except:
return " "
def add_note(user_id, location, note):
with open("notes.json", "r") as file:
data = json.load(file)
data = add_entry(user_id, location, data, note)
with open("notes.json", "w") as file:
json.dump(data, file)
def add_entry(user_id, location, data, note):
new_data = data
index = 0
for d in data:
print(d)
for key in d.keys():
print(key)
if key == str(user_id):
print(new_data[index][key])
ind = 0
for k in d[key]:
for lo in k.keys():
if lo == location:
del new_data[index][key][ind][lo]
break
ind += 1
new_data[index][key].append({location: note})
return new_data
index += 1
new_data.append({user_id: [{location: note}]})
return new_data
def current_time():
return datetime.now().strftime("%H:%M:%S")