mirror of https://gitlab.com/litecord/litecord.git
Compare commits
No commits in common. "6a617cf37650060c365f6fcef539d85d0a158508" and "ddd246906624971f40af8798f1673bb7639435d9" have entirely different histories.
6a617cf376
...
ddd2469066
|
|
@ -16,3 +16,4 @@ You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,23 +94,6 @@ async def adduser(ctx, args):
|
||||||
print(f'\tdiscrim: {user["discriminator"]}')
|
print(f'\tdiscrim: {user["discriminator"]}')
|
||||||
|
|
||||||
|
|
||||||
async def addbot(ctx, args):
|
|
||||||
uid, _ = await create_user(args.username, args.email, args.password)
|
|
||||||
|
|
||||||
await ctx.db.execute(
|
|
||||||
"""
|
|
||||||
UPDATE users
|
|
||||||
SET bot=True
|
|
||||||
WHERE id = $1
|
|
||||||
""",
|
|
||||||
uid,
|
|
||||||
)
|
|
||||||
|
|
||||||
args.user_id = uid
|
|
||||||
|
|
||||||
return await generate_bot_token(ctx, args)
|
|
||||||
|
|
||||||
|
|
||||||
async def set_flag(ctx, args):
|
async def set_flag(ctx, args):
|
||||||
"""Setting a 'staff' flag gives the user access to the Admin API.
|
"""Setting a 'staff' flag gives the user access to the Admin API.
|
||||||
Beware of that.
|
Beware of that.
|
||||||
|
|
@ -155,8 +138,7 @@ async def generate_bot_token(ctx, args):
|
||||||
)
|
)
|
||||||
|
|
||||||
if not password_hash:
|
if not password_hash:
|
||||||
print("cannot find a bot with specified id")
|
return print("cannot find a bot with specified id")
|
||||||
return 1
|
|
||||||
|
|
||||||
print(make_token(args.user_id, password_hash))
|
print(make_token(args.user_id, password_hash))
|
||||||
|
|
||||||
|
|
@ -216,14 +198,6 @@ def setup(subparser):
|
||||||
|
|
||||||
setup_test_parser.set_defaults(func=adduser)
|
setup_test_parser.set_defaults(func=adduser)
|
||||||
|
|
||||||
addbot_parser = subparser.add_parser("addbot", help="create a bot")
|
|
||||||
|
|
||||||
addbot_parser.add_argument("username", help="username of the bot")
|
|
||||||
addbot_parser.add_argument("email", help="email of the bot")
|
|
||||||
addbot_parser.add_argument("password", help="password of the bot")
|
|
||||||
|
|
||||||
addbot_parser.set_defaults(func=addbot)
|
|
||||||
|
|
||||||
setflag_parser = subparser.add_parser(
|
setflag_parser = subparser.add_parser(
|
||||||
"setflag", help="set a flag for a user", description=set_flag.__doc__
|
"setflag", help="set a flag for a user", description=set_flag.__doc__
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ def main(config):
|
||||||
async def _ctx_wrapper(fake_app, args):
|
async def _ctx_wrapper(fake_app, args):
|
||||||
app = fake_app.make_app()
|
app = fake_app.make_app()
|
||||||
async with app.app_context():
|
async with app.app_context():
|
||||||
return await args.func(fake_app, args)
|
await args.func(fake_app, args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if len(argv) < 2:
|
if len(argv) < 2:
|
||||||
|
|
@ -107,9 +107,8 @@ def main(config):
|
||||||
init_app_managers(app, init_voice=False)
|
init_app_managers(app, init_voice=False)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return loop.run_until_complete(_ctx_wrapper(app, args))
|
loop.run_until_complete(_ctx_wrapper(app, args))
|
||||||
except Exception:
|
except Exception:
|
||||||
log.exception("error while running command")
|
log.exception("error while running command")
|
||||||
return 1
|
|
||||||
finally:
|
finally:
|
||||||
loop.run_until_complete(app.db.close())
|
loop.run_until_complete(app.db.close())
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue