From c6a4f032fa3153537a72bed77a0158865916a87c Mon Sep 17 00:00:00 2001 From: iou1name Date: Sat, 10 Feb 2018 19:28:07 -0500 Subject: [PATCH] thread watching --- modules/bq.py | 3 +-- modules/movie.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/bq.py b/modules/bq.py index 8e90986..160360c 100755 --- a/modules/bq.py +++ b/modules/bq.py @@ -1,5 +1,4 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 """ Various things related to Banished Quest. """ diff --git a/modules/movie.py b/modules/movie.py index d54f86f..d4ea197 100755 --- a/modules/movie.py +++ b/modules/movie.py @@ -1,5 +1,4 @@ -#! /usr/bin/env python3 -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 """ This module exracts various information from imbd. 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: \ 1941 | Rating: 8.4 | Genre: Drama, Mystery | IMDB Link: \ http://imdb.com/title/tt0033467') -def movie(bot, trigger): +def movieInfo(bot, trigger): """ Returns some information about a movie, like Title, Year, Rating, Genre and IMDB Link. """ - if not trigger.group(2): + if not trigger.group().replace(".movie ", ""): return - word = trigger.group(2).strip().replace(" ", "+") + word = trigger.group().replace(".movie ", "").strip().replace(" ", "+") api_key = bot.config.movie.tmdb_api_key uri = "https://api.themoviedb.org/3/search/movie?" + \ @@ -125,11 +124,15 @@ def pickMovie(bot, trigger): cur = conn.cursor() cur.execute("SELECT movie_title FROM movie WHERE " + \ "times_watched < 1 AND shitpost = 0 ORDER BY RANDOM() LIMIT 1;") - movie = cur.fetchone() + movie = cur.fetchone()[0] conn.close() 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