@@ -526,7 +526,7 @@ def add(self, *args):
526526 i = 1
527527 row = []
528528 for button in args :
529- row .append (button .to_json ())
529+ row .append (button .to_dic ())
530530 if i % self .row_width == 0 :
531531 self .keyboard .append (row )
532532 row = []
@@ -571,13 +571,16 @@ def __init__(self, text, request_contact=None, request_location=None):
571571 self .request_location = request_location
572572
573573 def to_json (self ):
574+ return json .dumps (self .to_dic ())
575+
576+ def to_dic (self ):
574577 json_dic = {'text' : self .text }
575578 if self .request_contact :
576579 json_dic ['request_contact' ] = self .request_contact
577580 if self .request_location :
578581 json_dic ['request_location' ] = self .request_location
582+ return json_dic
579583
580- return json .dump (json_dic )
581584
582585
583586class InlineKeyboardMarkup (JsonSerializable ):
@@ -598,7 +601,7 @@ def add(self, *args):
598601 i = 1
599602 row = []
600603 for button in args :
601- row .append (button .to_json ())
604+ row .append (button .to_dic ())
602605 if i % self .row_width == 0 :
603606 self .keyboard .append (row )
604607 row = []
@@ -627,6 +630,7 @@ def to_json(self):
627630 return json .dumps (json_dict )
628631
629632
633+
630634class InlineKeyboardButton (JsonSerializable ):
631635 def __init__ (self , text , url = None , callback_data = None , switch_inline_query = None ):
632636 self .text = text
@@ -635,15 +639,17 @@ def __init__(self, text, url=None, callback_data=None, switch_inline_query=None)
635639 self .switch_inline_query = switch_inline_query
636640
637641 def to_json (self ):
642+ return json .dumps (self .to_dic ())
643+
644+ def to_dic (self ):
638645 json_dic = {'text' : self .text }
639646 if self .url :
640647 json_dic ['url' ] = self .url
641648 if self .callback_data :
642649 json_dic ['callback_data' ] = self .callback_data
643650 if self .switch_inline_query :
644651 json_dic ['switch_inline_quer' ] = self .switch_inline_quer
645- return json .dump (json_dic )
646-
652+ return json_dic
647653
648654class CallbackQuery (JsonDeserializable ):
649655 @classmethod
@@ -969,3 +975,4 @@ def to_json(self):
969975 if self .description :
970976 json_dict ['description' ] = self .description
971977 return json .dumps (json_dict )
978+
0 commit comments