Commit e2fdf272 authored by Otthorn's avatar Otthorn 🤔

fixed ugly rewrite of already existing functions

parent 9deaf566
......@@ -77,10 +77,3 @@ class MatrixBotAPI:
# Starts polling for messages
self.client.start_listener_thread()
return self.client.sync_thread
def upload_to_server(self, data, mime):
mxc = self.client.upload(data, mime)
return mxc
def get_user_by_id(self, user_id):
return self.client.get_user(user_id)
......@@ -108,8 +108,7 @@ def gif_callback(room, event):
print("GIF called with query={} in room={}".format(query, room.display_name))
data, mime = gif_search(query)
mxc_url = bot.upload_to_server(data, mime)
# cette fonction est une réécriture degeux -> à refaire !
mxc_url = bot.client.upload(data, mime)
room.send_image(mxc_url, query, mimetype=mime)
......@@ -149,7 +148,7 @@ def list_quote_callback(room, event):
args = event['content']['body']
user_id = get_id_from_link(args)
author_obj = bot.get_user_by_id(user_id)
author_obj = bot.client.get_user(user_id)
author = author_obj.get_friendly_name()
if len(args) == 1:
......@@ -171,6 +170,7 @@ def list_quote_callback(room, event):
def main():
# Add a regex handler waiting for the word Hi
hi_handler = MRegexHandler("Bonjour|Bonsoir|bonjour|bonsoir|Salut|salut", hi_callback)
bot.add_handler(hi_handler)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment