示例#1
0
文件: 4chan.py 项目: kgc/botmily
def fourchan(message_data, bot):
    board = ''
    if message_data['command'] == "anime":
        board = "/a/"
    if message_data['command'] == "dick":
        board = "/d/"
    if message_data['command'] == "technology":
        board = "/g/"
    if message_data['command'] == "videogame":
        board = "/v/"
    if message_data['command'] == "animals":
        board = "/an/"
    if message_data['command'] == "hentai":
        board = "/h/"
    if message_data['command'] == "ecchi":
        board = "/e/"
    if message_data['command'] == "pokemon":
        board = "/vp/"

    result = urlopen('http://boards.4chan.org' + board)
    soup = BeautifulStoneSoup(result, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
    images = soup.findAll('a', attrs={'class': 'fileThumb'})
    url = 'http:' + random.choice(images)['href']
    if message_data['parsed'] != "":
        makeMacro.makeMacro(url, message_data['parsed'], "temp.jpg")
        url = imgur.postToImgur(str("temp.jpg"))
    return url
示例#2
0
文件: face.py 项目: kgc/botmily
def face(message_data, bot):
    imgurl = message_data["parsed"]
    invalid = checkValidImage(imgurl)
    if invalid:
        return invalid   
    result = faceapi.Detect(imgurl)
    result = faceapi.cleanTags(result)
    characteristics = faceapi.makeBlurb(result)
    if characteristics:
        img = faceSquares.drawTags(result['photos'][0]['tags'],imgurl)
        img.save('temp.png', 'PNG')
        postedUrl = imgur.postToImgur(str('temp.png'))
        return characteristics + ', what I saw %s' %postedUrl
    else:
        return "Couldn't find a face, you are too ugly maybe :("
示例#3
0
def fourchan(message_data, bot):
    board = ''

    # Commands that should be treated as gross:
    pm_commands = ["slurm","j","dudes","ecchi","hentai","dick"]

    # This could have been a dict btw lol
    if message_data['command'] == "anime":
        board = "/a/"
    elif message_data['command'] == "dick":
        board = "/d/"
    elif message_data['command'] == "dudes":
        board = "/hm/"
    elif message_data['command'] == "j":
        board = "/s/"
    elif message_data['command'] == "slurm":
        board = "/lgbt/"
    elif message_data['command'] == "technology":
        board = "/g/"
    elif message_data['command'] == "videogame":
        board = "/v/"
    elif message_data['command'] == "animals":
        board = "/an/"
    elif message_data['command'] == "hentai":
        board = "/h/"
    elif message_data['command'] == "ecchi":
        board = "/e/"
    elif message_data['command'] == "pokemon":
        board = "/vp/"

    result = urlopen('http://boards.4chan.org' + board)
    soup = BeautifulSoup(result.read()) #BeautifulStoneSoup(result, convertEntities=BeautifulStoneSoup.HTML_ENTITIES)
    images = soup.find_all('a',class_='fileThumb') #soup.findAll('a', attrs={'class': 'fileThumb'})
    url = 'http:' + random.choice(images)['href']
    if message_data['parsed'] != "":
        makeMacro.makeMacro(url, message_data['parsed'], "temp.jpg")
        url = imgur.postToImgur(str("temp.jpg"))

    if message_data['command'] in pm_commands:
        return {"output":url, "channel": bot.nickname}
    else:
        return url