aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrumeet <yuuta@yuuta.moe>2021-02-27 14:48:41 -0800
committerTrumeet <yuuta@yuuta.moe>2021-02-27 14:48:41 -0800
commit255aaa9c26a37e37e68767c3aa265af5b30aa33d (patch)
tree837507a6f08a1596e04815d577398bb93c4d6f83
parent93ee12ae3a15ac00ec4fb2ac113699dd14e12d61 (diff)
downloadminebridge-255aaa9c26a37e37e68767c3aa265af5b30aa33d.tar
minebridge-255aaa9c26a37e37e68767c3aa265af5b30aa33d.tar.gz
minebridge-255aaa9c26a37e37e68767c3aa265af5b30aa33d.tar.bz2
minebridge-255aaa9c26a37e37e68767c3aa265af5b30aa33d.zip
feat: limit admin commands
-rw-r--r--README13
-rw-r--r--main.c14
2 files changed, 24 insertions, 3 deletions
diff --git a/README b/README
index 51f3385..a24bb5c 100644
--- a/README
+++ b/README
@@ -18,7 +18,7 @@ make install
CONFIGURATION
-TG_ADMIN=114514 # UID allowed to execute rcon commands other than /list. Equivalent to OP4.
+TG_ADMIN=114514 # UID allowed to execute more rcon commands other than /list. A complete list of commands supported is listed below.
TG_CHAT=-114514 # Chat that is allowed to send message to and from.
TG_LINK_FMT=https://t.me/c/xxx/%d # Format of Telegram links. %d: Message ID.
TG_API=114514:1919810 # Telegram bot API Key.
@@ -34,6 +34,17 @@ LIMITATIONS
Cannot start the server if it is not running.
+COMMANDS
+
+Any users in the chat can use `/list` or `/list uuids` to check online players.
+
+In additional to these two commands, the administrator can use the following commands as well:
+
+`/debug `
+`/data `
+`/whitelist `
+`/reload`
+
ACKNOWLEDGEMENTS
mcrcon: https://github.com/Tiiffi/mcrcon/tree/b02201d689b3032bc681b28f175fd3d83d167293
diff --git a/main.c b/main.c
index 5dd7507..d130318 100644
--- a/main.c
+++ b/main.c
@@ -114,8 +114,18 @@ run:
if(entity.offset == 0 &&
!strcmp(entity.type, "bot_command"))
{
- if(tgmsg->from->id == env->tg_admin ||
- !strcmp(tgmsg->text, "/list"))
+ char is_admin = tgmsg->from->id == env->tg_admin;
+ if((is_admin && (
+ !strncmp(tgmsg->text, "/whitelist ", strlen("/whitelist ")) ||
+ !strncmp(tgmsg->text, "/debug ", strlen("/debug ")) ||
+ !strncmp(tgmsg->text, "/data ", strlen("/data ")) ||
+ !strcmp(tgmsg->text, "/reload")
+ )) ||
+ (
+ !strcmp(tgmsg->text, "/list") ||
+ !strcmp(tgmsg->text, "/list uuids")
+ )
+ )
{
is_command = 1;
strcpy(msg, tgmsg->text + 1);