diff --git a/README.md b/README.md
index 5df5207..31e6a57 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,18 @@
A [maubot](https://github.com/maubot/maubot) to get information about movies from [TheMovieDB.org](https://www.themoviedb.org/).
## Usage
-Use `!movie-help` to get help about the bot usage.
+Use `!tmdb help` to get help about the bot usage.
-Use `!movie-id {tmdb id}` to get movie detail for tmdb-id.
+Use `!tmdb id movie {tmdb id}` to get movie detail for tmdb-id.
-Use `!movie-search {title} [y:{release year}]` to get movie detail based on the given title.
+Use `!tmdb movie {title} [y:{release year}]` to get movie detail based on the given title.
-Use `!movie-language {language}` to set your prefered language.
+Use `!tmdb language {language}` to set your prefered language.
-Use `!tvshow-search {title}` to get detail about a tv show based on the given title.
+Use `!tmdb tvshow {title}` to get detail about a tv show based on the given title.
## Discussion
Matrix room: [#tmdb-bot:matrix.sarkasti.eu](https://matrix.to/#/#tmdb-bot:matrix.sarkasti.eu)
-## Avator
+## Avatar
Avatar icons was made by [inipagistudio](https://www.flaticon.com/authors/inipagistudio) from [www.flaticon.com](https://www.flaticon.com/)
\ No newline at end of file
diff --git a/test_tmdb.py b/test_tmdb.py
index ac8f3af..574c8c9 100644
--- a/test_tmdb.py
+++ b/test_tmdb.py
@@ -95,7 +95,7 @@ class TestTmdbMethods(unittest.TestCase):
def test_cast(self):
movie = TvShow()
movie.search_title('The Flash')
- self.assertEqual('Grant Gustin', movie.cast[0])
+ self.assertEqual('Tom Cavanagh', movie.cast[0])
self.assertEqual('Carlos Valdes', movie.cast[2])
if __name__ == '__main__':
diff --git a/tmdb/tmdb.py b/tmdb/tmdb.py
index 7b0da4c..4155874 100644
--- a/tmdb/tmdb.py
+++ b/tmdb/tmdb.py
@@ -55,11 +55,17 @@ class TmdbBot(Plugin):
formatted_body=f"{html_message}")
await evt.respond(content)
+ async def send_notice(self, evt: MessageEvent, message: str = "") -> None:
+ content = TextMessageEventContent(
+ msgtype=MessageType.NOTICE, format=Format.HTML,
+ body=message)
+ await evt.respond(content)
+
async def send_help(self, evt: MessageEvent) -> None:
- html = """Use !movie-id {tmdb id} to get movie detail for tmdb-id.
- Use !movie-search {title} [y:{release year}] to get movie detail based on the given title.
- Use !movie-language {language} to set your prefered language.
- Use !tvshow-search {title} to get detail about a tv show based on the given title."""
+ html = """Use !tmdb id movie {tmdb id} to get movie detail for tmdb-id.
+ Use !tmdb movie {title} [y:{release year}] to get movie detail based on the given title.
+ Use !tmdb language {language} to set your prefered language.
+ Use !tmdb tvshow {title} to get detail about a tv show based on the given title."""
content = TextMessageEventContent(
msgtype=MessageType.TEXT, format=Format.HTML,
body=f"Help for TMDB Bot",
@@ -103,8 +109,6 @@ class TmdbBot(Plugin):
await self.send_html_message(evt, f'{movie.title}', html_message)
await self.send_image(evt, movie.title, movie.get_image_binary())
- @command.new("movie-id", help="Movie lookup by id")
- @command.argument("message", pass_raw=True, required=True)
async def movie_id(self, evt: MessageEvent, message: str = "") -> None:
movie = Movie()
language = self.db.get_language(evt.sender)
@@ -113,8 +117,11 @@ class TmdbBot(Plugin):
movie.query_details(message)
await self.send_movie_info(evt, movie)
- @command.new("movie-search", help="Movie lookup by Title")
+ @command.new("movie-id", help="Movie lookup by id")
@command.argument("message", pass_raw=True, required=True)
+ async def command_movie_id(self, evt: MessageEvent, message: str = "") -> None:
+ await self.movie_id(evt, message)
+
async def movie_search(self, evt: MessageEvent, message: str = "") -> None:
movie = Movie()
language = self.db.get_language(evt.sender)
@@ -130,8 +137,11 @@ class TmdbBot(Plugin):
body=f"No movie found!")
await evt.respond(content)
- @command.new("movie-language", help="Set language for lookup")
+ @command.new("movie-search", help="Movie lookup by Title")
@command.argument("message", pass_raw=True, required=True)
+ async def command_movie_search(self, evt: MessageEvent, message: str = "") -> None:
+ await self.movie_search(evt, message)
+
async def movie_language(self, evt: MessageEvent, message: str = "") -> None:
self.db.set_language(evt.sender, message)
content = TextMessageEventContent(
@@ -139,6 +149,11 @@ class TmdbBot(Plugin):
body=f"Language set to {message}!")
await evt.respond(content)
+ @command.new("movie-language", help="Set language for lookup")
+ @command.argument("message", pass_raw=True, required=True)
+ async def command_movie_language(self, evt: MessageEvent, message: str = "") -> None:
+ await self.movie_language(evt, message)
+
@command.new("movie-help", help="Help for TMDB Bot")
async def movie_help(self, evt: MessageEvent, message: str = "") -> None:
await self.send_help(evt)
@@ -147,8 +162,6 @@ class TmdbBot(Plugin):
async def tvshow_help(self, evt: MessageEvent, message: str = "") -> None:
await self.send_help(evt)
- @command.new("tvshow-search", help="TV Show lookup by Title")
- @command.argument("message", pass_raw=True, required=True)
async def tvshow_search(self, evt: MessageEvent, message: str = "") -> None:
movie = TvShow()
language = self.db.get_language(evt.sender)
@@ -158,7 +171,40 @@ class TmdbBot(Plugin):
if movie.valid:
await self.send_movie_info(evt, movie)
else:
- content = TextMessageEventContent(
- msgtype=MessageType.NOTICE, format=Format.HTML,
- body=f"No tv show found!")
- await evt.respond(content)
+ await self.send_notice("No tv show found!")
+
+ @command.new("tvshow-search", help="TV Show lookup by Title")
+ @command.argument("message", pass_raw=True, required=True)
+ async def command_tvshow_search(self, evt: MessageEvent, message: str = "") -> None:
+ await self.tvshow_search(evt, message)
+
+ @command.new("tmdb", help="TMDB Bot")
+ @command.argument("message", pass_raw=True, required=True)
+ async def command_dispatcher(self, evt: MessageEvent, message: str = "") -> None:
+ m = re.search(r'^([^\s]*)\s*(.*)', message)
+ if m:
+ command = m.group(1)
+ parameters = m.group(2)
+ if command.lower() == 'help':
+ await self.send_help(evt)
+ elif command.lower() == 'movie':
+ await self.movie_search(evt, parameters)
+ elif command.lower() == 'language':
+ await self.movie_language(evt, parameters)
+ elif command.lower() == 'tvshow':
+ await self.tvshow_search(evt, parameters)
+ elif command.lower() == 'id':
+ m = re.search(r'^(movie|tvshow) (\d*)', parameters)
+ if m:
+ type = m.group(1)
+ id = m.group(2)
+ if type.lower() == 'movie':
+ await self.movie_id(evt, id)
+ elif type.lower() == 'tvshow':
+ await self.send_notice(evt, 'Not yet implemented. Search TV shows by title for now (!tmdb tvshow {title})')
+ else:
+ await self.send_notice(evt, 'Syntax wrong: !tmdb id {movie|tvshow} {tmdb id}')
+ else:
+ await self.send_notice(evt, 'Syntax wrong: !tmdb id {movie|tvshow} {tmdb id}')
+ else:
+ await self.send_notice(evt, 'Command unknown!')
\ No newline at end of file