Return a gif based on search of several *reactions
        Ported to Legobot from:
            "https://github.com/ricardokirkner/err-devops-reactions"
            ... and extended.

        Return a random gif if no query is specified or query not found

        Example:
            !devopsy somefoofulquery
            !devopsy

def devopsy(self, *args):
        """Return a gif based on search of several *reactions
        Ported to Legobot from:
            "https://github.com/ricardokirkner/err-devops-reactions"
            ... and extended.

        Return a random gif if no query is specified or query not found

        Example:
            !devopsy somefoofulquery
            !devopsy
        """

        args = ' '.join(self.message['text'].split()[1:])
        if args:
            base_main = {
                'dev': 'https://devopsreactions.tumblr.com/',
                'sec': 'https://securityreactions.tumblr.com/'
            }
            main_items = list(base_main.items())
            key, val = random.choice(main_items)  # nosec
        else:
            base_alt = {
                'qa': 'https://qareacts.tumblr.com/',
                'dba': 'http://dbareactions.com/'
            }
            alt_items = list(base_alt.items())
            key, val = random.choice(alt_items)  # nosec

        if args and set(('dev', 'sec')) <= set(base_main):
            q = urlencode({'q': args})
            path = ''.join(['?', q])
        else:
            path = 'random'
        url = urljoin(val, path)
        r = requests.get(url)
        logger.debug('url sent: {}'.format(r.url))

        if r.ok:
            dom = PyQuery(r.content)
            results = dom('div[class=post_title] a')
            logger.debug('results found: {}'.format(len(results)))
        else:
            results = []

        if results:
            item = random.choice(results)  # nosec
            img = item.get('href')
            response = img
        else:
            path = 'random'
            noway = urljoin(url, path)
            response = 'Foo for you: {}'.format(noway)
        return response