@@ -1178,6 +1178,26 @@ def editMessageReplyMarkup(
1178
1178
1179
1179
return url , data
1180
1180
1181
+ def create_references (self , d ):
1182
+ """
1183
+ Recursively reates a reference to this Bot instance in the dict and all contained dicts and
1184
+ lists of dicts. This reference can then be retrieved in constructors to be used in class
1185
+ methods like ``Message.reply_text``.
1186
+
1187
+ Args:
1188
+ d (dict): The dict to create the references in.
1189
+ """
1190
+
1191
+ for value in d .values ():
1192
+ if isinstance (value , list ):
1193
+ for item in value :
1194
+ self .create_references (item )
1195
+
1196
+ elif isinstance (value , dict ):
1197
+ self .create_references (value )
1198
+
1199
+ d ['bot' ] = self
1200
+
1181
1201
@log
1182
1202
def getUpdates (self , offset = None , limit = 100 , timeout = 0 , network_delay = 5. , ** kwargs ):
1183
1203
"""Use this method to receive incoming updates using long polling.
@@ -1221,10 +1241,14 @@ def getUpdates(self, offset=None, limit=100, timeout=0, network_delay=5., **kwar
1221
1241
1222
1242
if result :
1223
1243
self .logger .debug ('Getting updates: %s' , [u ['update_id' ] for u in result ])
1244
+
1224
1245
else :
1225
1246
self .logger .debug ('No new updates found.' )
1226
1247
1227
- return [Update .de_json (x ) for x in result ]
1248
+ for u in result :
1249
+ self .create_references (u )
1250
+
1251
+ return [Update .de_json (u ) for u in result ]
1228
1252
1229
1253
@log
1230
1254
def setWebhook (self , webhook_url = None , certificate = None , ** kwargs ):
0 commit comments