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
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