Skip to content
This repository was archived by the owner on Jul 31, 2018. It is now read-only.

Commit 9bdee36

Browse files
authored
Merge pull request #6 from verixx/rewrite
update
2 parents 7ddf473 + 8d6bf7d commit 9bdee36

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

cogs/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ async def update(self, ctx):
10001000
async with ctx.session.get('https://api.github.com/user', headers={"Authorization": f"Bearer {git.githubtoken}"}) as res:
10011001
if 300 > res.status >= 200:
10021002
# create pr
1003-
async with ctx.session.post('https://api.github.com/repos/' + (await res.json())['login'] + '/selfbot.py/pulls', json={"title": "Updating Bot", "body": "Body", "head": "verixx:rewrite", "base": "rewrite"}, headers={"Authorization": f"Bearer {git.githubtoken}"}) as resp:
1003+
async with ctx.session.post('https://api.github.com/repos/' + (await res.json())['login'] + '/selfbot.py/pulls', json={"title": "Updating Bot", "head": "verixx:rewrite", "base": "rewrite"}, headers={"Authorization": f"Bearer {git.githubtoken}"}) as resp:
10041004
if 300 > resp.status >= 200:
10051005
# merge pr
10061006
async with ctx.session.put(str((await resp.json())['url']) + '/merge', headers={"Authorization": f"Bearer {git.githubtoken}"}) as resp2:
@@ -1081,9 +1081,11 @@ async def rpoll(self, ctx, *, args):
10811081

10821082
@commands.group(invoke_without_command=True)
10831083
async def cc(self, ctx):
1084+
'''Custom Commands!'''
10841085
if not await git.starred('verixx/selfbot.py'): return await ctx.send('This command is disabled as the user have not starred <https://github.com/verixx/selfbot.py>')
10851086
@cc.command(aliases=['create', 'add'])
10861087
async def make(self, ctx, name, *, content):
1088+
'''Create a custom command!'''
10871089
if not await git.starred('verixx/selfbot.py'): return await ctx.send('This command is disabled as the user have not starred <https://github.com/verixx/selfbot.py>')
10881090
git = self.bot.get_cog('Git')
10891091
with open('data/cc.json') as f:
@@ -1098,7 +1100,9 @@ async def make(self, ctx, name, *, content):
10981100
await ctx.send('Use `cc edit` to edit this command as it already exists.')
10991101
@cc.command()
11001102
async def edit(self, ctx, name, *, content):
1103+
'''Edits a currently existing custom command'''
11011104
if not await git.starred('verixx/selfbot.py'): return await ctx.send('This command is disabled as the user have not starred <https://github.com/verixx/selfbot.py>')
1105+
git = self.bot.get_cog('Git')
11021106
try:
11031107
commands[name]
11041108
except KeyError:
@@ -1109,7 +1113,9 @@ async def edit(self, ctx, name, *, content):
11091113
await ctx.send('Edited command.')
11101114
@cc.command()
11111115
async def delete(self, ctx, *, name):
1116+
'''Deletes a custom command'''
11121117
if not await git.starred('verixx/selfbot.py'): return await ctx.send('This command is disabled as the user have not starred <https://github.com/verixx/selfbot.py>')
1118+
git = self.bot.get_cog('Git')
11131119
try:
11141120
commands[name]
11151121
except KeyError:

ext/context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,12 @@ async def failure(self, msg=None):
122122
async def updatedata(self, path:str, content, commitmsg='No Commit Message'):
123123
'''To edit data in Github'''
124124
git = self.bot.get_cog('Git')
125+
#get username
125126
username = await git.githubusername()
127+
#get sha (dont even know why this is a compulsory field)
126128
async with self.session.get(f'https://api.github.com/repos/{username}/selfbot.py/contents/{path}') as resp2:
127129
if 300 > resp2.status >= 200:
130+
#push to path
128131
async with self.session.put(f'https://api.github.com/repos/{username}/selfbot.py/contents/{path}', headers={"Authorization": f"Bearer {git.githubtoken}"}, json={"path":"data/cc.json", "message":commitmsg, "content":base64.b64encode(bytes(str(content).replace("'", '"'), 'utf-8')).decode('ascii'), "sha":(await resp2.json())['sha'], "branch":"rewrite"}) as resp3:
129132
if 300 > resp3.status >= 200:
130133
return True

0 commit comments

Comments
 (0)