<commit_before>"""
Local pmxbot extensions, incude the path to this file in your config.yaml.
"""

import random
import urllib

from pmxbot import command, execdelay

@command("yahoolunch", doc="Find a random neary restaurant for lunch using "
    "Yahoo Local. Defaults to 1 mile radius, but append Xmi to the end to "
    "change the radius.")
def lunch(client, event, channel, nick, rest):
    yahooid = "eeGETYOUROWN.yu"
    from yahoo.search.local import LocalSearch
    location = rest.strip()
    if location.endswith('mi'):
        radius, location = ''.join(reversed(location)).split(' ', 1)
        location = ''.join(reversed(location))
        radius = ''.join(reversed(radius))
        radius = float(radius.replace('mi', ''))
    else:
        radius = 1
    srch = LocalSearch(app_id=yahooid, category=96926236, results=20,
        query="lunch", location=location, radius=radius)
    res = srch.parse_results()
    limit = min(250, res.totalResultsAvailable)
    num = random.randint(1, limit) - 1
    if num < 19:
        selection = res.results[num]
    else:
        srch = LocalSearch(app_id=yahooid, category=96926236, results=20,
            query="lunch", location=location, start=num)
        res = srch.parse_results()
        selection = res.results[0]
    return '{Title} @ {Address} - {Url}'.format(**selection)

@command("paste", aliases=(), doc="Drop a link to your latest paste on "
    "http://libpa.st")
def paste(client, event, channel, nick, rest):
    request = urllib.urlopen("http://libpa.st/last/%s" % nick)
    post_url = request.geturl()
    if post_url and request.getcode() == 200:
        return post_url
    else:
        return ("hmm.. I didn't find a recent paste of yours, %s. Checkout "
            "http://libpa.st" % nick)

@execdelay("hi", channel="#botone", howlong=10)
def howdy(client, event):
    return "Howdy everybody!"<commit_msg>0-19 are the first 20<commit_after>"""
Local pmxbot extensions, incude the path to this file in your config.yaml.
"""

import random
import urllib

from pmxbot import command, execdelay

@command("yahoolunch", doc="Find a random neary restaurant for lunch using "
    "Yahoo Local. Defaults to 1 mile radius, but append Xmi to the end to "
    "change the radius.")
def lunch(client, event, channel, nick, rest):
    yahooid = "eeGETYOUROWN.yu"
    from yahoo.search.local import LocalSearch
    location = rest.strip()
    if location.endswith('mi'):
        radius, location = ''.join(reversed(location)).split(' ', 1)
        location = ''.join(reversed(location))
        radius = ''.join(reversed(radius))
        radius = float(radius.replace('mi', ''))
    else:
        radius = 1
    srch = LocalSearch(app_id=yahooid, category=96926236, results=20,
        query="lunch", location=location, radius=radius)
    res = srch.parse_results()
    limit = min(250, res.totalResultsAvailable)
    num = random.randint(1, limit) - 1
    if num < 20:
        selection = res.results[num]
    else:
        srch = LocalSearch(app_id=yahooid, category=96926236, results=20,
            query="lunch", location=location, start=num)
        res = srch.parse_results()
        selection = res.results[0]
    return '{Title} @ {Address} - {Url}'.format(**selection)

@command("paste", aliases=(), doc="Drop a link to your latest paste on "
    "http://libpa.st")
def paste(client, event, channel, nick, rest):
    request = urllib.urlopen("http://libpa.st/last/%s" % nick)
    post_url = request.geturl()
    if post_url and request.getcode() == 200:
        return post_url
    else:
        return ("hmm.. I didn't find a recent paste of yours, %s. Checkout "
            "http://libpa.st" % nick)

@execdelay("hi", channel="#botone", howlong=10)
def howdy(client, event):
    return "Howdy everybody!"
{'fraction_non_alphanumeric': 0.13753959873284055, 'fraction_numerical': 0.020327349524815207, 'mean_word_length': 3.257303370786517, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '28577', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1188, 'n_words': 337}