12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- def upload_to_slack(pictures, slack_bot):
- """Uploads the pictures to slack and a message depending on request situation.
- Checks the temp request file for a request and sends messages depending on,
- if there is a request.
- If the last request ran out, this person is getting notified.
- If not, tell person, trigger has been received.
- Upload to slack
- """
- channel = get_key('Slack', 'channel_name')
- request = slack_bot.queue.get()
- if request['request']:
- if time() <= request['ts']:
- message = "Received the trigger in time, you will get the photo!"
- channel = request['channel']
- else:
- # Hmm, this should never happen ... keep it in, just to be sure
- message = "Hey, sorry but you missed your request window, but I told you that."
- SlackBot.send_ephemeral_message(SlackBot,
- msg=message,
- user=request['user'],
- channel=request['channel'])
- # Make sure we pick the right file
- SlackBot.upload_file(SlackBot, pictures[0], channel)
- send_feedback(Message.UPLOAD)
- if get_bool_key('Output', 'enhance'):
- SlackBot.upload_file(SlackBot, pictures[1], channel)
- if request['request']:
- request['request'] = False
- request['user'] = None
- request['real_name'] = None
- request['channel'] = None
- request['ts'] = float(get_key('Slack', 'request_period'))
- slack_bot.queue.put(request)
- print("after slack upload")
|