22
22
SOFTWARE.
23
23
'''
24
24
25
- __version__ = '1.4.3 '
25
+ __version__ = '1.4.4 '
26
26
27
27
from contextlib import redirect_stdout
28
28
from urllib .parse import urlparse
@@ -233,6 +233,22 @@ async def data_loop(self):
233
233
234
234
await asyncio .sleep (3600 )
235
235
236
+ async def get_latest_updates (self , limit = 3 ):
237
+ latest_commits = ''
238
+
239
+ async for commit in Github (self ).get_latest_commits (limit = limit ):
240
+
241
+ short_sha = commit ['sha' ][:6 ]
242
+ html_url = commit ['html_url' ]
243
+ message = commit ['commit' ]['message' ]
244
+ author_name = commit ['author' ]['login' ]
245
+ author_url = commit ['author' ]['html_url' ]
246
+
247
+ latest_commits += f'[`{ short_sha } `]({ html_url } ) { message } - { author_name } \n '
248
+
249
+ return latest_commits
250
+
251
+
236
252
@property
237
253
def uptime (self ):
238
254
now = datetime .datetime .utcnow ()
@@ -271,6 +287,7 @@ async def about(self, ctx):
271
287
'improved upon suggestions by the users! This bot serves as a means for members to ' \
272
288
'easily communicate with server leadership in an organised manner.'
273
289
290
+
274
291
try :
275
292
async with self .session .get ('https://api.kybr.tk/modmail' ) as resp :
276
293
meta = await resp .json ()
@@ -282,8 +299,12 @@ async def about(self, ctx):
282
299
em .add_field (name = 'Instances' , value = meta ['instances' ])
283
300
else :
284
301
em .add_field (name = 'Latency' , value = f'{ self .latency * 1000 :.2f} ms' )
302
+
303
+
285
304
em .add_field (name = 'Version' , value = f'[`{ __version__ } `](https://github.com/kyb3r/modmail/blob/master/bot.py#L25)' )
286
305
em .add_field (name = 'Author' , value = '[`kyb3r`](https://github.com/kyb3r)' )
306
+
307
+ em .add_field (name = 'Latest Updates' , value = await self .get_latest_updates ())
287
308
288
309
footer = f'Bot ID: { self .user .id } '
289
310
@@ -319,25 +340,14 @@ async def update(self, ctx):
319
340
color = discord .Color .green ()
320
341
)
321
342
343
+ em .add_field (name = 'Latest Commit' , value = await self .get_latest_updates (limit = 1 ), inline = False )
344
+
322
345
access_token = self .config .get ('GITHUB_ACCESS_TOKEN' )
323
346
324
347
if data ['latest_version' ] == __version__ :
325
348
if access_token :
326
349
user = await Github .login (self , access_token )
327
350
em .set_author (name = user .username , icon_url = user .avatar_url , url = user .url )
328
-
329
- latest_commits = ''
330
-
331
- async for commit in Github (self ).get_latest_commits ():
332
-
333
- short_sha = commit ['sha' ][:6 ]
334
- html_url = commit ['html_url' ]
335
- message = commit ['commit' ]['message' ]
336
- author_name = commit ['author' ]['login' ]
337
- author_url = commit ['author' ]['html_url' ]
338
-
339
- latest_commits += f'[`{ short_sha } `]({ html_url } ) { message } - [`{ author_name } `]({ author_url } )\n '
340
-
341
351
342
352
if data ['latest_version' ] != __version__ :
343
353
if not access_token :
@@ -350,6 +360,8 @@ async def update(self, ctx):
350
360
351
361
em .color = discord .Color .red ()
352
362
return await ctx .send (embed = em )
363
+
364
+ em .set_footer (text = f"Updating modmail v{ __version__ } -> v{ data ['latest_version' ]} " )
353
365
354
366
user = await Github .login (self , access_token )
355
367
data = await user .update_repository ()
@@ -365,9 +377,7 @@ async def update(self, ctx):
365
377
em .add_field (name = 'Merge Commit' , value = f'[`{ short_sha } `]({ html_url } ) { message } - [`{ user .username } `]({ user .url } )' )
366
378
else :
367
379
em .description = 'Already up to date with master repository.'
368
-
369
- em .add_field (name = 'Latest Updates' , value = latest_commits , inline = False )
370
-
380
+
371
381
await ctx .send (embed = em )
372
382
373
383
@commands .command ()
0 commit comments