Queer European MD passionate about IT
فهرست منبع

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

Davte 5 سال پیش
والد
کامیت
5927dcd30f
1فایلهای تغییر یافته به همراه3 افزوده شده و 2 حذف شده
  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