Added get_title #1

Merged
khuxkm merged 4 commits from aewens/sotdbot:master into master 2018-11-15 23:09:50 +00:00

6
bot.py
View File

@ -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):