-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPoints.py
64 lines (57 loc) · 1.68 KB
/
Points.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
# PyBot is a Twitch IRC chatbot used particularly for spamming your chat, but as well as a general chatbot for doing whatever.
# Copyright (C) 2016-2018 Sheep44
#
# This file is part of PyBot.
#
# PyBot is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License.
#
# PyBot is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# NOTE: Move from username to user ID
import threading
from requests import request as req
from Settings import CHANNEL, PASS
from time import sleep as t
from os.path import isfile
_pointsList = {}
chatInfo = {}
_pointsFileName = "points/" + CHANNEL + ".json"
def points():
global _pointsList
global chatInfo
justStarted = True
if isfile(_pointsFileName):
try:
_pointsList = eval(open(_pointsFileName, 'r'))
except:
__ = open(_pointsFileName, 'w')
__.close()
del __
while True:
chatInfo = eval(
req(
method="GET",
url="https://tmi.twitch.tv/group/user/%s/chatters" % CHANNEL
).text
)
chatters = chatInfo["chatters"]
if justStarted:
justStarted = False
else:
for x in chatters:
for i in chatInfo["chatters"][x]:
if i in _pointsList.keys() and "bot" not in i:
_pointsList[i] += 5
elif "bot" not in i:
_pointsList[i] = 5
with open(_pointsFileName, 'w') as f:
f.write(str(_pointsList))
f.close()
t(60)
thread = threading.Thread(target=points)
thread.daemon = True
thread.start()