-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommander.py
More file actions
55 lines (45 loc) · 1.48 KB
/
Copy pathCommander.py
File metadata and controls
55 lines (45 loc) · 1.48 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from CommandSourceInterface import CommandSourceInterface as CSI
import Queue
from SaltyBot import SaltyBot
from threading import Thread
import time
class Commander(object):
messages = Queue.Queue()
tickSpeed = .5 #in seconds
slaves = []
slaveThreads = []
@property
def numSlaves(self):
return len(self.slaves)
def __init__(self):
pass
def run(self):
[bot.start() for bot in self.slaveThreads if bot is not None]
while True:
message = self.messages.get(True, 6000)
if type(message) is str:
print(message)
time.sleep(self.tickSpeed)
[bot.join() for bot in self.slaveThreads if bot is not None] #TODO: note that this doesn't do anything right now
def addBot(self, player, factor, amount, email, password, waitTime):
if type(waitTime) != int or waitTime < 0:
print("Negative wait times are not possible.")
exit()
bot = SaltyBot(waitTime=waitTime)
wager = None
wagerFunc = None
if amount > 0:
wagerFunc = bot.wagerAmount
wager = amount
elif factor > 0 and factor < 100:
wagerFunc = bot.wagerPercent
wager = factor / 100.0
else:
print("Please use either a positive amount or a factor between 1 and 100.")
exit()
bot.login(email=email, password=password)
bot.messagingFunc = self.messages.put
self.slaves.append(bot)
botThread = Thread(target=bot.run, args=(wagerFunc, player, wager))
botThread.daemon = True
self.slaveThreads.append(botThread)