-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfirstpost_processor.py
executable file
·45 lines (36 loc) · 1.2 KB
/
firstpost_processor.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
#! /usr/bin/env python3
import time
import config
import channel
import channel_configuration
import slack_token
import slacker
import message_writer
import firstpost
class Downloader(object):
def __init__(self, sname, stoken):
self.cconfig = channel_configuration.ChannelConfiguration()
self.slack = slacker.Slacker(sname, stoken)
self.MessageWriter = message_writer.MessageWriter()
self.channel = channel.Channel()
self.fp = firstpost.FirstPost()
def download(self):
cids = self.slack.get_all_channel_ids()
cid_count = len(cids)
idx = 1
for cid in cids:
channel_entry = self.channel.get(cid)
if channel_entry:
name = channel_entry['friendly_name']
else:
name = "Unknown"
m = "Getting messages for {}/{} {} - {}"
m = m.format(idx, cid_count, cid, name)
print(m)
idx += 1
self.fp.set_channel(cid)
messages = self.slack.get_messages(cid, 0, self.fp.message)
self.fp.save()
if __name__ == "__main__":
downloader = Downloader("rands-leadership", slack_token.token)
downloader.download()