-
Notifications
You must be signed in to change notification settings - Fork 34
/
raw.py
49 lines (40 loc) · 1.79 KB
/
raw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# minqlbot - A Quake Live server administrator bot.
# Copyright (C) 2015 Mino <mino@minomino.org>
# This file is part of minqlx.
# minqlx is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# minqlx is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with minqlx. If not, see <http://www.gnu.org/licenses/>.
# Used mostly for debug. A potential security issue, since it allows
# level 5 people to execute arbitrary Python code on your server.
import minqlx
class raw(minqlx.Plugin):
def __init__(self):
self.add_command(("exec", "pyexec"), self.cmd_exec, 5,
client_cmd_pass=False, usage="<python_code>")
self.add_command(("eval", "pyeval"), self.cmd_eval, 5,
client_cmd_pass=False, usage="<python_code>")
def cmd_exec(self, player, msg, channel):
if len(msg) < 2:
return minqlx.RET_USAGE
else:
try:
exec(" ".join(msg[1:]))
except Exception as e:
channel.reply("^1{}^7: {}".format(e.__class__.__name__, e))
raise
def cmd_eval(self, player, msg, channel):
if len(msg) < 2:
return minqlx.RET_USAGE
else:
try:
channel.reply(str(eval(" ".join(msg[1:]))))
except Exception as e:
channel.reply("^1{}^7: {}".format(e.__class__.__name__, e))
raise