Skip to content

Commit

Permalink
Added urlencoding
Browse files Browse the repository at this point in the history
  • Loading branch information
TomCasavant committed Apr 8, 2019
1 parent a10c300 commit a0d1904
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions giphy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Type
import urllib.parse
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
from maubot import Plugin, MessageEvent
from maubot.handlers import command
Expand Down Expand Up @@ -26,11 +27,10 @@ async def handler(self, evt: MessageEvent, search_term: str) -> None:
# If user doesn't supply a search term, set to empty string
search_term = ""
api_key = self.config["api_key"]
url_params = urllib.parse.urlencode({"tag": search_term, "api_key": api_key})
# Get random gif url using search term
async with self.http.get(
"http://api.giphy.com/v1/gifs/random?tag={}&api_key={}".format(
search_term, api_key
)
"http://api.giphy.com/v1/gifs/random?{}".format(url_params)
) as response:
data = await response.json()
gif_link = data.get("data", {}).get("image_url")
Expand Down

0 comments on commit a0d1904

Please sign in to comment.