Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

needed more business cat #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

needed more business cat #10

wants to merge 4 commits into from

Conversation

dguido
Copy link

@dguido dguido commented Jan 20, 2015

This PR adds a simple business cat plugin. It watches for any text matching known business jargon and responds with a randomly chosen business cat image. Jargon and images were taken from hubot-business-cat (MIT licensed).

@llimllib
Copy link
Owner

Not ignoring you, btw, I just merged the tests branch, but I don't have plugin tests yet and I don't trust PRs until I do. Coming soon!

@dguido
Copy link
Author

dguido commented Jan 23, 2015

Oh cool you have tests now. I should start using those.

@topher200
Copy link
Collaborator

topher200 commented Oct 9, 2017

I spot checked ~6 of the imgur images and all their links still work! (go imgur!)


I started writing what a test file for plugin would be but I got hung up on a question: was this supposed to use re.match? ie: are we supposed to only match on input text that starts with a trigger phrase? It seems like re.search may have been the intended target (so we match if the trigger phrase is anywhere in the input text).

Certain triggers definitely seem like re.search was the intended behavior. See this trigger:

    "(\\W|^)buy(\\s|-)in",

That doesn't make much sense with re.match, but does with re.search.


Anyway, here's a start of what the plugin test file might look like (currently failing, see comment in file):

import os
import sys

DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(DIR, '../../limbo/plugins'))

from business_cat import on_message

def __we_get_response(text):
    ret = on_message({"text": text}, None)
    assert '.jpg' in ret

def test_business_cat():
    __we_get_response(u'action item')
    __we_get_response(u'action items')
    __we_get_response(u'action items extra words')
    __we_get_response(u'action items extra words')

    __we_get_response(u'buy in')

    ### these currently fail, due to re.match only matching on the start of an input phrase
    __we_get_response(u'get buy in')
    __we_get_response(u'get buy-in')
    __we_get_response(u'get buy-in extra words')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants