-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.py
42 lines (37 loc) · 1.56 KB
/
driver.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
from pprint import pprint
import string
import groupy
REPLACEABLE_CHARS = """0123456789!"#$%&'()*+,-./:;<=>?@[\]^_`{|}"""
def get_messages():
groups = groupy.Group.list()
for group in groups:
if group.name == 'PML':
messages = group.messages()
iters = int((group.message_count / 100))
print("Total iters needed: " + str(iters))
msg = []
# for message in group.messages():
i = 1
with open(group.name, 'w') as f:
for message in messages:
message = message.text
if message:
message = message.replace('\n', ' ')
message = str(message.encode('ascii', errors='ignore'))
for letter in REPLACEABLE_CHARS:
message = message.replace(letter, ' ')
f.write(message)
while i <= iters:
print("Iteration: " + str(i))
messages = messages.older()
for message in messages:
message = message.text
if message:
message = message.replace('\n', ' ')
message = str(message.encode('ascii', errors='ignore'))
for letter in REPLACEABLE_CHARS:
message = message.replace(letter, ' ')
f.write(message)
i += 1
if __name__ == '__main__':
get_messages()