Queer European MD passionate about IT
Bläddra i källkod

Dump int, list and dict parameters as strings for API calls

Davte 5 år sedan
förälder
incheckning
5927dcd30f
1 ändrade filer med 3 tillägg och 2 borttagningar
  1. 3 2
      davtelepot/api.py

+ 3 - 2
davtelepot/api.py

@@ -6,6 +6,7 @@ A simple aiohttp asyncronous web client is used to make requests.
 
 # Standard library modules
 import asyncio
+import json
 import logging
 
 # Third party modules
@@ -98,8 +99,8 @@ class TelegramBot(object):
         data = aiohttp.FormData()
         for key, value in parameters.items():
             if not (key in exclude or value is None):
-                if type(value) is int:
-                    value = str(value)
+                if type(value) in (int, dict, list,):
+                    value = json.dumps(value, separators=(',', ':'))
                 data.add_field(key, value)
         return data