|
22 | 22 | SOFTWARE.
|
23 | 23 | '''
|
24 | 24 |
|
25 |
| -__version__ = '1.4.1' |
| 25 | +__version__ = '1.4.2' |
26 | 26 |
|
27 | 27 | from contextlib import redirect_stdout
|
28 | 28 | from urllib.parse import urlparse
|
@@ -122,7 +122,6 @@ async def on_ready(self):
|
122 | 122 | ---------------
|
123 | 123 | '''))
|
124 | 124 |
|
125 |
| - |
126 | 125 | async def on_message(self, message):
|
127 | 126 | if message.author.bot:
|
128 | 127 | return
|
@@ -326,43 +325,47 @@ async def update(self, ctx):
|
326 | 325 | if access_token:
|
327 | 326 | user = await Github.login(self, access_token)
|
328 | 327 | em.set_author(name=user.username, icon_url=user.avatar_url, url=user.url)
|
329 |
| - return await ctx.send(embed=em) |
| 328 | + |
| 329 | + latest_commits = '' |
330 | 330 |
|
331 |
| - if not access_token: |
332 |
| - em.title = 'Invalid Access Token' |
333 |
| - em.description = 'You have not properly set up GitHub credentials. '\ |
334 |
| - 'Create a config variable named `GITHUB_ACCESS_TOKEN`'\ |
335 |
| - ' and set the value as your personal access token which'\ |
336 |
| - ' can be generated in your GitHub account\'s [developer '\ |
337 |
| - 'settings](https://github.com/settings/tokens).' |
| 331 | + async for commit in Github(self).get_latest_commits(): |
338 | 332 |
|
339 |
| - em.color = discord.Color.red() |
340 |
| - return await ctx.send(embed=em) |
341 |
| - |
342 |
| - user = await Github.login(self, access_token) |
343 |
| - resp = await user.request(user.head) |
344 |
| - sha, commit_url = resp['object']['sha'], resp['object']['url'] |
345 |
| - data = await user.update_repository(sha) |
| 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'] |
346 | 338 |
|
347 |
| - latest_update = await user.request(commit_url) |
| 339 | + latest_commits += f'[`{short_sha}`]({html_url}) {message} - [`{author_name}`]({author_url})\n' |
348 | 340 |
|
349 |
| - em.title = 'Success' |
350 |
| - em.set_author(name=user.username, icon_url=user.avatar_url, url=user.url) |
351 |
| - |
352 |
| - if data: |
353 |
| - em.description = 'Bot successfully updated, the bot will restart momentarily' |
354 |
| - message = data['commit']['message'] |
355 |
| - html_url = data["html_url"] |
356 |
| - short_sha = data['sha'][:6] |
357 |
| - em.add_field(name='Merge Commit', value=f'[`{short_sha}`]({html_url}) - {message}') |
358 |
| - else: |
359 |
| - em.description = 'Already up to date with master repository.' |
360 |
| - |
361 | 341 |
|
362 |
| - short_sha = latest_update['sha'][:6] |
363 |
| - html_url = latest_update['html_url'] |
364 |
| - message = latest_update['message'] |
365 |
| - em.add_field(name='Latest Commit', value=f'[`{short_sha}`]({html_url}) - {message}', inline=False) |
| 342 | + if data['latest_version'] != __version__: |
| 343 | + if not access_token: |
| 344 | + em.title = 'Invalid Access Token' |
| 345 | + em.description = 'You have not properly set up GitHub credentials. '\ |
| 346 | + 'Create a config variable named `GITHUB_ACCESS_TOKEN`'\ |
| 347 | + ' and set the value as your personal access token which'\ |
| 348 | + ' can be generated in your GitHub account\'s [developer '\ |
| 349 | + 'settings](https://github.com/settings/tokens).' |
| 350 | + |
| 351 | + em.color = discord.Color.red() |
| 352 | + return await ctx.send(embed=em) |
| 353 | + user = await Github.login(self, access_token) |
| 354 | + data = await user.update_repository() |
| 355 | + |
| 356 | + em.title = 'Success' |
| 357 | + em.set_author(name=user.username, icon_url=user.avatar_url, url=user.url) |
| 358 | + |
| 359 | + if data: |
| 360 | + em.description = 'Bot successfully updated, the bot will restart momentarily' |
| 361 | + message = data['commit']['message'] |
| 362 | + html_url = data["html_url"] |
| 363 | + short_sha = data['sha'][:6] |
| 364 | + em.add_field(name='Merge Commit', value=f'[`{short_sha}`]({html_url}) {message} - [`{user.name}`]({user.url})') |
| 365 | + else: |
| 366 | + em.description = 'Already up to date with master repository.' |
| 367 | + |
| 368 | + em.add_field(name='Latest Updates', value=latest_commits, inline=False) |
366 | 369 |
|
367 | 370 | await ctx.send(embed=em)
|
368 | 371 |
|
|
0 commit comments