Ejemplo n.º 1
0
from tank import Tank
brewer = None
tank = None

print('Listening to Slack...')
try:
	while True:
		for notification in Chat.getNotifications():
			Chat.processNotification(notification)
		while True:
			action = Chat.getNextAction()
			if action is None:
				break
			if brewer and brewer.isAlive():
				Chat.talk('Oh I\'m kind of busy now! Please wait a bit and I\'ll take your order @{0}.'
					.format(action['user']['name']),
					channel=action['notification']['channel'])
				continue
			# Spam a brewing process.
			brewer = Brewer(action['isShort'], action['notification']['channel'],
				action['user'])
			brewer.start()
		if not tank or not tank.isAlive() and not Chat.isDisabled():
			# Spam a tank check process.
			tank = Tank()
			tank.start()
		time.sleep(0.5)
finally:
	Senseo.disablePump()
	Senseo.close()
Ejemplo n.º 2
0
brewer = None
tank = None

print('Listening to Slack...')
try:
    while True:
        for notification in Chat.getNotifications():
            Chat.processNotification(notification)
        while True:
            action = Chat.getNextAction()
            if action is None:
                break
            if brewer and brewer.isAlive():
                Chat.talk(
                    'Oh I\'m kind of busy now! Please wait a bit and I\'ll take your order @{0}.'
                    .format(action['user']['name']),
                    channel=action['notification']['channel'])
                continue
            # Spam a brewing process.
            brewer = Brewer(action['isShort'],
                            action['notification']['channel'], action['user'])
            brewer.start()
        if not tank or not tank.isAlive() and not Chat.isDisabled():
            # Spam a tank check process.
            tank = Tank()
            tank.start()
        time.sleep(0.5)
finally:
    Senseo.disablePump()
    Senseo.close()