Added get_title #1
6
bot.py
6
bot.py
|
@ -1,4 +1,5 @@
|
|||
import teambot, time, datastore
|
||||
from urllib.request import urlopen
|
||||
|
||||
USAGE = dict(admin="Stop trying to use this command!",sotd="{}sotd <link> <name>",listsotd="{}listsotd")
|
||||
PUBLIC_COMMANDS = ["sotd","listsotd"]
|
||||
|
@ -6,7 +7,10 @@ PUBLIC_COMMANDS = ["sotd","listsotd"]
|
|||
SOTDS = datastore.DataStore("sotd.json")
|
||||
|
||||
def get_title(link):
|
||||
return link # TODO: actually make this get the title of a link.
|
||||
title = str(urlopen(link).read()).split("<title>", 1)[1].split("</title>", 1)[0]
|
||||
if "YouTube" in title:
|
||||
return title.split(" - Youtube", 1)[0]
|
||||
return title
|
||||
|
||||
class SOTDBot(teambot.Handler,teambot.CommandHandlerMixin):
|
||||
def __init__(self,*args):
|
||||
|
|
Reference in New Issue
Block a user