-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTwitterModule.py
More file actions
38 lines (32 loc) · 1.2 KB
/
TwitterModule.py
File metadata and controls
38 lines (32 loc) · 1.2 KB
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
# -*- coding: utf-8 -*-
import os
import json
import CBE
class TwitterModule(CBE.CBEModule):
def __init__(self, cbe, name):
super(TwitterModule, self).__init__(cbe)
self.useTick = True
self.Interval = 5
self.NextFetchTime = 0.
self.OutputFile = "TwitterFollowers.txt"
self.Headers = {'Authorization': 'Bearer FDF7u89fdC998875c8d7f'}
self.Url = "https://cdn.syndication.twimg.com/widgets/followbutton/info.json?screen_names=" + name
def CheckConfig(self):
return
def RegisterUI(self):
return
def RegisterCommands(self):
return
def RegisterHelp(self):
return
def Tick(self):
if self.cbe.GetBotLifetime() > self.NextFetchTime:
followers = json.loads(eval(self.cbe.GetRequest(self.Url, self.Headers))["response"])[0]["followers_count"]
with open(os.path.join(self.cbe.Path, self.OutputFile), "w") as ctf:
ctf.write(str(followers).encode('utf-8'))
self.NextFetchTime = self.cbe.GetBotLifetime() + self.Interval
try:
pass
except Exception as e:
self.cbe.Log(str(e), "TwitterModule")
return