Exemplo n.º 1
0
def weather(event, **kwargs):
    """Weather event handler for Slack webhook events
    """
    text = kwargs.get('text')
    command = kwargs.get('command')
    args = kwargs.get('args')

    if command == 'weather':
        if args:
            location = args
            from htk.lib.forecastio.utils import format_weather
            from htk.utils.text.converters import markdown2slack
            from htk.utils.weather import get_weather
            weather = get_weather(location)
            formatted_weather = format_weather(weather)
            slack_text = '*Weather for %s*:\n%s' % (
                location,
                markdown2slack(formatted_weather),
            )
        else:
            slack_text = 'Please specify a location to retrieve weather for.'
    else:
        slack_text = 'Illegal command.'

    channel = event['channel_id']
    username = '******'

    payload = {
        'text' : slack_text,
        'username' : username,
    }
    return payload
Exemplo n.º 2
0
def weather(event, **kwargs):
    """Weather event handler for Slack webhook events
    """
    text = kwargs.get('text')
    command = kwargs.get('command')
    args = kwargs.get('args')
    icon_emoji = None

    if command == 'weather':
        if args:
            location = args
            from htk.lib.darksky.utils import generate_weather_report
            from htk.utils.text.converters import markdown2slack
            from htk.utils.weather import get_weather
            weather = get_weather(location)
            formatted_weather = generate_weather_report(weather, extended=True)
            slack_text = '*Weather for %s*:\n%s' % (
                location,
                markdown2slack(formatted_weather['summary']),
            )
            icon_emoji = formatted_weather.get('icon_emoji')
        else:
            slack_text = 'Please specify a location to retrieve weather for.'
    else:
        slack_text = 'Illegal command.'

    channel = event['channel_id']

    payload = {
        'text': slack_text,
        'icon_emoji': icon_emoji,
    }
    return payload
Exemplo n.º 3
0
def weather(event, **kwargs):
    """Weather event handler for Slack webhook events
    """
    text = kwargs.get('text')
    command = kwargs.get('command')
    args = kwargs.get('args')
    icon_emoji = None

    if command == 'weather':
        if args:
            location = args
            from htk.lib.darksky.utils import generate_weather_report
            from htk.utils.text.converters import markdown2slack
            from htk.utils.weather import get_weather
            weather = get_weather(location)
            formatted_weather = generate_weather_report(weather, extended=True)
            slack_text = '*Weather for %s*:\n%s' % (
                location,
                markdown2slack(formatted_weather['summary']),
            )
            icon_emoji = formatted_weather.get('icon_emoji')
        else:
            slack_text = 'Please specify a location to retrieve weather for.'
    else:
        slack_text = 'Illegal command.'

    channel = event['channel_id']

    payload = {
        'text' : slack_text,
        'icon_emoji' : icon_emoji,
    }
    return payload
Exemplo n.º 4
0
 def remind_pull_requests(self):
     markdown_content, attachments = self.pull_request_reminder()
     from htk.utils.text.converters import markdown2slack
     slack_text = markdown2slack(markdown_content)
     from htk.lib.slack.utils import webhook_call
     webhook_call(webhook_url=self.slack_webhook_url,
                  channel=self.slack_channel,
                  text=slack_text,
                  attachments=attachments,
                  username='******',
                  icon_emoji=':octocat:',
                  unfurl_links=False)
Exemplo n.º 5
0
 def remind_pull_requests(self):
     markdown_content, attachments = self.pull_request_reminder()
     from htk.utils.text.converters import markdown2slack
     slack_text = markdown2slack(markdown_content)
     from htk.lib.slack.utils import webhook_call
     webhook_call(
         webhook_url=self.slack_webhook_url,
         channel=self.slack_channel,
         text=slack_text,
         attachments=attachments,
         username='******',
         icon_emoji=':octocat:',
         unfurl_links=False
     )