thread watching

This commit is contained in:
iou1name 2018-02-10 19:28:07 -05:00
parent 446b53db61
commit c6a4f032fa
2 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
Various things related to Banished Quest. Various things related to Banished Quest.
""" """

View File

@ -1,5 +1,4 @@
#! /usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" """
This module exracts various information from imbd. This module exracts various information from imbd.
It also contains functionality for the local movie database. It also contains functionality for the local movie database.
@ -22,14 +21,14 @@ def setup(bot):
@module.example('.movie Citizen Kane', '[MOVIE] Title: Citizen Kane | Year: \ @module.example('.movie Citizen Kane', '[MOVIE] Title: Citizen Kane | Year: \
1941 | Rating: 8.4 | Genre: Drama, Mystery | IMDB Link: \ 1941 | Rating: 8.4 | Genre: Drama, Mystery | IMDB Link: \
http://imdb.com/title/tt0033467') http://imdb.com/title/tt0033467')
def movie(bot, trigger): def movieInfo(bot, trigger):
""" """
Returns some information about a movie, like Title, Year, Rating, Returns some information about a movie, like Title, Year, Rating,
Genre and IMDB Link. Genre and IMDB Link.
""" """
if not trigger.group(2): if not trigger.group().replace(".movie ", ""):
return return
word = trigger.group(2).strip().replace(" ", "+") word = trigger.group().replace(".movie ", "").strip().replace(" ", "+")
api_key = bot.config.movie.tmdb_api_key api_key = bot.config.movie.tmdb_api_key
uri = "https://api.themoviedb.org/3/search/movie?" + \ uri = "https://api.themoviedb.org/3/search/movie?" + \
@ -125,11 +124,15 @@ def pickMovie(bot, trigger):
cur = conn.cursor() cur = conn.cursor()
cur.execute("SELECT movie_title FROM movie WHERE " + \ cur.execute("SELECT movie_title FROM movie WHERE " + \
"times_watched < 1 AND shitpost = 0 ORDER BY RANDOM() LIMIT 1;") "times_watched < 1 AND shitpost = 0 ORDER BY RANDOM() LIMIT 1;")
movie = cur.fetchone() movie = cur.fetchone()[0]
conn.close() conn.close()
bot.memory['movie_lock'].release() bot.memory['movie_lock'].release()
bot.reply(movie[0]) bot.reply(movie)
if trigger.group(2) == "-m":
trigger.set_group(f".movie {movie}")
movieInfo(bot, trigger)
@module.require_admin @module.require_admin