diff --git a/plugins/imdb.py b/plugins/imdb.py new file mode 100644 index 0000000..53a8fe2 --- /dev/null +++ b/plugins/imdb.py @@ -0,0 +1,21 @@ +# IMDb lookup plugin by Ghetto Wizard (2011). + +from util import hook, http + + +@hook.command +def imdb(inp): + '''.imdb -- gets information about from IMDb''' + + content = http.get_json("http://www.imdbapi.com/", t=inp) + + if content['Response'] == 'Movie Not Found': + return 'movie not found' + elif content['Response'] == 'True': + content['URL'] = 'http://www.imdb.com/title/%(ID)s' % content + + return "\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s " \ + "\x02%(Runtime)s\x02. \x02%(Rating)s/10\x02 with " \ + "\x02%(Votes)s\x02 votes. %(URL)s" % content + else: + return 'unknown error' diff --git a/plugins/quote.py b/plugins/quote.py index b8a4e8d..e42b0ad 100644 --- a/plugins/quote.py +++ b/plugins/quote.py @@ -12,6 +12,11 @@ def add_quote(db, chan, nick, add_nick, msg): db.commit() +def del_quote(db, chan, nick, add_nick, msg): + db.execute('''update quote set deleted = 1 where + chan=? and lower(nick)=lower(?) and msg=msg''') + db.commit() + def get_quotes_by_nick(db, chan, nick): return db.execute("select time, nick, msg from quote where deleted!=1 " "and chan=? and lower(nick)=lower(?) order by time", @@ -90,3 +95,48 @@ def quote(inp, nick='', chan='', db=None): selected_quote = quotes[num - 1] return format_quote(selected_quote, num, n_quotes) + + +@hook.command('qdel', adminonly=True) +@hook.command +def quotedelete: + ".qdel/.quotedelete [#chan] [nick] <#n>/.quote add -- deletes " \ + "<#n>th quote by or from <#chan> (adminonly)" + + retrieve = re.match(r"(\S+)(?:\s+#?(-?\d+))?$", inp) + retrieve_chan = re.match(r"(#\S+)\s+(\S+)(?:\s+#?(-?\d+))?$", inp) + + if retrieve: + select, num = retrieve.groups() + + by_chan = False + if select.startswith('#'): + by_chan = True + quotes = get_quotes_by_chan(db, select) + else: + quotes = get_quotes_by_nick(db, chan, select) + elif retrieve_chan: + chan, nick, num = retrieve_chan.groups() + + quotes = get_quotes_by_nick(db, chan, nick) + else: + return quote.__doc__ + + n_quotes = len(quotes) + + if not n_quotes: + return "no quotes found" + + num = int(num) + + if num > n_quotes or (num < 0 and num < -n_quotes): + return "I only have %d quote%s for %s" % (n_quotes, + ('s', '')[n_quotes == 1], select) + elif num < 0: + selected_quote = quotes[num] + num = n_quotes + num + 1 + else: + selected_quote = quotes[num - 1] + + return format_quote(selected_quote, num, n_quotes) +