add a way to execute commands through bitbotd (use for master-password)
This commit is contained in:
parent
352df0fa75
commit
9f8c5acf52
4 changed files with 16 additions and 7 deletions
|
@ -24,6 +24,8 @@ SIMPLE = ["rehash", "reload", "stop"]
|
||||||
if args.command == "log":
|
if args.command == "log":
|
||||||
arg_parser.add_argument("--level", "-l", help="Log level",
|
arg_parser.add_argument("--level", "-l", help="Log level",
|
||||||
default="INFO")
|
default="INFO")
|
||||||
|
elif args.command == "command":
|
||||||
|
arg_parser.add_argument("subcommand")
|
||||||
elif args.command in SIMPLE:
|
elif args.command in SIMPLE:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
@ -53,6 +55,8 @@ _send("0 version 0")
|
||||||
|
|
||||||
if args.command == "log":
|
if args.command == "log":
|
||||||
_send("1 log %s" % args.level)
|
_send("1 log %s" % args.level)
|
||||||
|
elif args.command == "command":
|
||||||
|
_send("1 command %s" % args.subcommand)
|
||||||
elif args.command in SIMPLE:
|
elif args.command in SIMPLE:
|
||||||
_send("1 %s" % args.command)
|
_send("1 %s" % args.command)
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
* Move `docs/bot.conf.example` to `~/.bitbot/bot.conf` and fill in the config options you care about. Ones blank or removed will disable relevant functionality.
|
* Move `docs/bot.conf.example` to `~/.bitbot/bot.conf` and fill in the config options you care about. Ones blank or removed will disable relevant functionality.
|
||||||
* Run `./bitbotd -a` to add a server.
|
* Run `./bitbotd -a` to add a server.
|
||||||
* Run `./bitbotd -m permissions -M master-password` to get the master admin password (needed to add regular admin accounts)
|
* Run `./bitbotctl command master-password` to get the master admin password (needed to add regular admin accounts)
|
||||||
* Run `./bitbotd` to start the bot.
|
* Run `./bitbotd` to start the bot.
|
||||||
* Join `#bitbot` on a server with the bot (or invite it to another channel)
|
* Join `#bitbot` on a server with the bot (or invite it to another channel)
|
||||||
* `/msg <bot> register <password here>` to register your nickname with the bot
|
* `/msg <bot> register <password here>` to register your nickname with the bot
|
||||||
|
|
|
@ -23,12 +23,10 @@ class Module(ModuleManager.BaseModule):
|
||||||
self.bot.set_setting("master-password", [hash, salt])
|
self.bot.set_setting("master-password", [hash, salt])
|
||||||
return master_password
|
return master_password
|
||||||
|
|
||||||
def command_line(self, args: str):
|
@utils.hook("control.master-password")
|
||||||
if args == "master-password":
|
def command_line(self, event):
|
||||||
master_password = self._master_password()
|
master_password = self._master_password()
|
||||||
print("one-time master password: %s" % master_password)
|
return "One-time master password: %s" % master_password
|
||||||
else:
|
|
||||||
raise ValueError("Unknown command-line argument")
|
|
||||||
@utils.hook("received.command.masterpassword", private_only=True)
|
@utils.hook("received.command.masterpassword", private_only=True)
|
||||||
def master_password(self, event):
|
def master_password(self, event):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -104,6 +104,13 @@ class Control(PollSource.PollSource):
|
||||||
keepalive = False
|
keepalive = False
|
||||||
elif command == "stop":
|
elif command == "stop":
|
||||||
self._bot.stop()
|
self._bot.stop()
|
||||||
|
elif command == "command" and data:
|
||||||
|
subcommand, _, data = data.partition(" ")
|
||||||
|
output = self._bot._events.on("control").on(subcommand
|
||||||
|
).call_for_result(data=data)
|
||||||
|
if not output == None:
|
||||||
|
response_data = output
|
||||||
|
keepalive = False
|
||||||
|
|
||||||
self._send_action(client, response_action, response_data, id)
|
self._send_action(client, response_action, response_data, id)
|
||||||
if not keepalive:
|
if not keepalive:
|
||||||
|
|
Loading…
Reference in a new issue