Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@sopel.module.rule('.*(https?:\/\/myanimelist.net\/anime\/(\d+).*((?=[\s])|$))')
def malirc(bot, trigger, match=None):
match = match or trigger
id = match.group(2)
url = 'https://myanimelist.net/includes/ajax.inc.php?t=64&id={}-id'.format(id)
bs, x = connect(url)
if bs.text == 'No such series found.':
return
if "... (" in (bs.find_all('a', {'class':'hovertitle'})[0].text):
name = bs.find_all('a', {'class':'hovertitle'})[0].text.split("...")[0].strip()
year = bs.find_all('a', {'class':'hovertitle'})[0].text.split("...")[1].strip()[1:-1]
else:
split = bs.find_all('a', {'class':'hovertitle'})[0].text.split(' (')
name = split[0]
year = split[1][0:-1]
status = bs.findAll('span',text='Status:')[0].nextSibling.strip()
episodes = bs.findAll('span',text='Episodes:')[0].nextSibling.strip()
@sopel.module.example('.gelbooru search_term or .gelbooru safe search_term')
def gel(bot, trigger):
if not trigger.group(2):
return bot.say("Enter a search term.")
search_term = trigger.split(' ')
search_term.pop(0)
bs, tags = get_gel_data(search_term)
if not bs:
return
if bs.find_all('posts')[0].get('count') == '0':
return bot.say('Nothing but us chickens!')
else:
total = bs.findAll('posts')[0].get('count')
bot.say('[{0} found] http://gelbooru.com/index.php?page=post&s=list&tags={1}'.format(total, tags))
@sopel.module.commands('[^ ]+')
def autocomplete(bot, tr):
funcs = [f for group in bot._callables.values() for f in group.values()]
funcs = {f for l in funcs for f in l if hasattr(f, 'commands')}
partial = tr.group(1)
if any(partial in f.commands for f in funcs):
return
funcs = [
f for f in funcs if any(c.startswith(partial) for c in f.commands)]
if not funcs:
return
if len(funcs) > 1:
bot.send(jarvis.tools.choose_input([f.commands[0] for f in funcs]))
else:
wrapper = bot.SopelWrapper(bot, tr)
bot.call(funcs[0], wrapper, tr)
@sopel.module.commands('hltb','howlong','howlongtobeat')
@sopel.module.example('.hltb game name')
def hltb(bot,trigger):
if not trigger.group(2):
return bot.say("Enter a game name to search.")
game = trigger.group(2)
url = "https://howlongtobeat.com/search_results.php?page=1"
payload = {"queryString":game,"t":"games","sorthead":"popular","sortd":"Normal Order","length_type":"main","detail":"0"}
test = {'Content-type':'application/x-www-form-urlencoded', 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36','origin':'https://howlongtobeat.com','referer':'https://howlongtobeat.com'}
session = requests.Session()
r = session.post(url, headers=test, data=payload)
if len(r.content) < 250:
return bot.say("No results.")
bs = BeautifulSoup(r.content, "html.parser")
first = bs.findAll("div", {"class":"search_list_details"})[0]
name = first.a.text
time = first.findAll('div')[3].text
@sopel.module.commands('author')
def find_author(bot, tr):
name = tr.group(2) if tr.group(2) else tr.nick
bot.send(jarvis.scp.find_author(name, tr.sender))
@sopel.module.rule('.*https?:\/\/anilist.co\/anime\/(\d.*?(?=\/))\/?.*?((?=[\s])|$)')
def anilistirc(bot,trigger, match=None):
match = match or trigger
x = aniquery(bot, trigger, id=match.group(1))
if not x.ok:
return
name = x.json()['data']['Media']['title']['romaji']
genres = ", ".join(x.json()['data']['Media']['genres'])
year = x.json()['data']['Media']['startDate']['year']
type = x.json()['data']['Media']['format']
episodes = x.json()['data']['Media']['episodes']
status = x.json()['data']['Media']['status']
return bot.say("{0} [{1}] - Type: {2} Eps: {3} Genres: {4} status: {5}".format(name, year, type, episodes, genres, status))
@sopel.module.commands('pixiven','pixen')
@sopel.module.example('.pixiven word')
def pixiven(bot,trigger):
#display = Display(visible=0, size=(1024,768))
#display.start()
#browser = webdriver.Firefox()
url = "http://www.pixiv.net/search.php?word="+urllib.request.quote(trigger.group(2))
bot.memory["pixbrowser"].get(url)
bs = BeautifulSoup(bot.memory["pixbrowser"].page_source, "html.parser")
truesearch = bs.find("link", {"rel":"canonical"}).get('href')
truesearchlink = 'http://www.pixiv.net/'+truesearch
results = (bs.find("span",{ "class": "count-badge"}).text).replace("results","")
bot.say("{0} results | {1}".format(results,truesearchlink))
#bot.memory["pixbrowser"].close()