Пример #1
1
def knife(bot, trigger):
    """
    Price compare between all available query engines
    """
    query = trigger.group(2)
    d = ddg()
    sites = [query_attributes("knifecenter.com",
                query_kc_knife,
                KCNAME_TO_DBNAME),
              query_attributes("bladehq.com",
                query_bhq_knife,
                BHQNAME_TO_DBNAME)]
    for qa in sites:
        s = qa.site
        d.query(query, site=s)
        if not d.results:
            bot.reply("I couldn't find anything with the search term {} at {}".format(query, s))
            return
        else:
            qa.url = d.results[0]
    comp_string = ""
    for qa in sites:
        if qa.url:
            knife = qa.fcn(qa.url)
            d = replaceDictKeys(qa.DBC, knife)
            qa.price = knife["Price"]
            comp_string += "[{site}:{price}] ".format(site=qa.site, price=qa.price)

    if(comp_string):
        bot.say(comp_string)
Пример #2
0
def knife(bot, trigger):
    query = trigger.group(2)
    if query == 'vero':
        bot.reply('For more information on Vero knives see https://veroengineering.com/')
        return
    d = ddg()
    d.bhq_safe_query(query, site="bladehq.com")
    #use the first result
    if not d.results:
        bot.reply("I couldn't find anything with the search term {}".format(query))
        return
    url = d.results[0]
    knife = query_bhq_knife(url)
    if not knife:
        bot.reply('Sorry I didn\'t find anything I could parse, but I did find this {url}'.format(url=url))
    else:
        # need to handle "product type" better ( search again if not knife )
        if knife["Product Type"] == "Knife":
            d = replaceDictKeys(BHQNAME_TO_DBNAME,knife)
            kf = KnifeFormatter()
            results_string = kf.formattedKnife(d)
            bot.reply(results_string)
        else:
            d = replaceDictKeys(BHQNAME_TO_DBNAME,knife)
            kf = KnifeFormatter()
            results_string = kf.formattedKnife(d)
            bot.reply("I know this isn't a knife, but its what i found:" + results_string)
Пример #3
0
def knife(bot, trigger):
    """
    Queries a knife center knife
    """
    query = trigger.group(2)
    d = ddg()
    d.query(query, site="knifecenter.com")
    #use the first result
    if not d.results:
        bot.reply("I couldn't find anything with the search term {}".format(query))
        return
    url = d.results[0]
    knife = query_kc_knife(url)
    if not knife:
        bot.reply('Sorry I didn\'t find anything I could parse, but I did find this {url}'.format(url=url))
    else:
        # need to handle "product type" better ( search again if not knife )
        d = replaceDictKeys(BHQNAME_TO_DBNAME,knife)
        kf = KnifeFormatter()
        results_string = kf.formattedKnife(d)
        bot.reply(results_string)
Пример #4
0
def knife(bot, trigger):
    """
    Queries a knife center knife
    """
    query = trigger.group(2)
    d = ddg()
    d.query(query, site="knifecenter.com")
    #use the first result
    if not d.results:
        bot.reply(
            "I couldn't find anything with the search term {}".format(query))
        return
    url = d.results[0]
    knife = query_kc_knife(url)
    if not knife:
        bot.reply(
            'Sorry I didn\'t find anything I could parse, but I did find this {url}'
            .format(url=url))
    else:
        # need to handle "product type" better ( search again if not knife )
        d = replaceDictKeys(BHQNAME_TO_DBNAME, knife)
        kf = KnifeFormatter()
        results_string = kf.formattedKnife(d)
        bot.reply(results_string)
Пример #5
0
def knife(bot, trigger):
    query = trigger.group(2)
    d = ddg()
    d.bhq_safe_query(query, site="bladehq.com")
    #use the first result
    if not d.results:
        bot.reply("I couldn't find anything with the search term {}".format(query))
        return
    url = d.results[0]
    knife = query_bhq_knife(url)
    if not knife:
        bot.reply('Sorry I didn\'t find anything I could parse, but I did find this {url}'.format(url=url))
    else:
        # need to handle "product type" better ( search again if not knife )
        if knife["Product Type"] == "Knife":
            d = replaceDictKeys(BHQNAME_TO_DBNAME,knife)
            kf = KnifeFormatter()
            results_string = kf.formattedKnife(d)
            bot.reply(results_string)
        else:
            d = replaceDictKeys(BHQNAME_TO_DBNAME,knife)
            kf = KnifeFormatter()
            results_string = kf.formattedKnife(d)
            bot.reply("I know this isn't a knife, but its what i found:" + results_string)