-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchunkedData.py
32 lines (24 loc) · 912 Bytes
/
chunkedData.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
import watcherLogging
# takes in a list and gives back list items in 1000 chars or less
# discord bot has a max value of 2000 so we will send in chunks below that
def get_chunked_data(yourList):
totalChars = 0
stringList = list()
stringChunk = ""
try:
for val in yourList:
stringChunk += val
# print(myStr)
#playerCount += 1
totalChars += int(len(val))
if totalChars >= 1000:
stringList.append(str(stringChunk + "\n"))
stringChunk = ''
#print('Total Chars:' , totalChars)
totalChars = 0
if(len(stringChunk) > 0):
stringList.append(str(stringChunk + '\n'))
except Exception as e:
print("Error get_chunked_data ERROR ::" + e)
watcherLogging.error_logs('Error get_chunked_data ERROR ::' + str(e))
return stringList