Skip to content

Commit 67816c3

Browse files
committed
added ability to add commands in chat, various little modifications
1 parent fa04fb4 commit 67816c3

File tree

5 files changed

+336
-335
lines changed

5 files changed

+336
-335
lines changed

Commands.py

Lines changed: 0 additions & 137 deletions
This file was deleted.

Points.py

Lines changed: 39 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# PyBot is a Twitch IRC chatbot used particularly for spamming your chat, but as well as a general chatbot for doing whatever.
2-
# Copyright (C) 2016 Sheep44
2+
# Copyright (C) 2016-2018 Sheep44
33
#
44
# This file is part of PyBot.
55
#
@@ -13,62 +13,50 @@
1313
# GNU General Public License for more details.
1414

1515

16+
# NOTE: Move from username to user ID
1617

17-
# This is an unfinished file and is not for use until it is patched up.
1818
import threading
19-
from Settings import CHANNEL
19+
from requests import request as req
20+
from Settings import CHANNEL, PASS
2021
from time import sleep as t
21-
import urllib.request
2222
from os.path import isfile
23-
printLock = threading.Lock()
23+
24+
2425
_pointsList = {}
26+
chatInfo = {}
27+
_pointsFileName = "points/" + CHANNEL + ".json"
2528
def points():
26-
justStarted = True
27-
global _pointsList
28-
_pointsFileName = "points_" + CHANNEL + ".json"
29-
if isfile(_pointsFileName):
30-
_pointsFileRead = open(_pointsFileName, 'r')
31-
_pointsList = eval(_pointsFileRead.read())
32-
while True:
33-
chatInfo = eval(urllib.request.urlopen("https://tmi.twitch.tv/group/user/" + CHANNEL + "/chatters").read())
34-
chatters = chatInfo["chatters"]
35-
mods = chatters["moderators"]
36-
staff = chatters["staff"]
37-
admins = chatters["admins"]
38-
gMods = chatters["global_mods"]
39-
viewers = chatters["viewers"]
40-
if justStarted:
41-
justStarted = False
42-
else:
43-
for i in viewers:
44-
if i in _pointsList.keys():
45-
_pointsList[i] += 5
46-
else:
47-
_pointsList[i] = 0
48-
for i in mods:
49-
if i in _pointsList.keys():
50-
_pointsList[i] += 5
51-
else:
52-
_pointsList[i] = 0
53-
for i in staff:
54-
if i in _pointsList.keys():
55-
_pointsList[i] += 5
56-
else:
57-
_pointsList[i] = 0
58-
for i in admins:
59-
if i in _pointsList.keys():
60-
_pointsList[i] += 5
61-
else:
62-
_pointsList[i] = 0
63-
for i in gMods:
64-
if i in _pointsList.keys():
65-
_pointsList[i] += 5
66-
else:
67-
_pointsList[i] = 0
68-
69-
_pointsFileWrite = open(_pointsFileName, 'w')
70-
_pointsFileWrite.write(str(_pointsList))
71-
t(60)
29+
global _pointsList
30+
global chatInfo
31+
justStarted = True
32+
if isfile(_pointsFileName):
33+
try:
34+
_pointsList = eval(open(_pointsFileName, 'r'))
35+
except:
36+
__ = open(_pointsFileName, 'w')
37+
__.close()
38+
del __
39+
while True:
40+
chatInfo = eval(
41+
req(
42+
method="GET",
43+
url="https://tmi.twitch.tv/group/user/%s/chatters" % CHANNEL
44+
).text
45+
)
46+
chatters = chatInfo["chatters"]
47+
if justStarted:
48+
justStarted = False
49+
else:
50+
for x in chatters:
51+
for i in chatInfo["chatters"][x]:
52+
if i in _pointsList.keys() and "bot" not in i:
53+
_pointsList[i] += 5
54+
elif "bot" not in i:
55+
_pointsList[i] = 5
56+
with open(_pointsFileName, 'w') as f:
57+
f.write(str(_pointsList))
58+
f.close()
59+
t(60)
7260

7361

7462
thread = threading.Thread(target=points)

0 commit comments

Comments
 (0)