-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathterminator.py
44 lines (37 loc) · 1.08 KB
/
terminator.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
# -*- coding: utf-8 -*-
# vim:set ts=8 sts=8 sw=8 tw=80 noet cc=80:
from module import Module, COMMAND
class Terminator(Module):
def __init__(self, **keywords):
super(Terminator, self).__init__([COMMAND], name=__name__,
**keywords)
self.target = None
def register(self):
self.send_cmd("register_cli", name=["set", "target"], argc=1,
undo=False)
self.send_cmd("register_cli", name=["kill", "it"], argc=0,
undo=False)
def unregister(self):
self.send_cmd("unregister_cli", name=["set", "target"], argc=1)
self.send_cmd("unregister_cli", name=["kill", "it"], argc=0)
def start(self):
self.register()
def stop(self):
self.unregister()
def command(self, cmd, **keywords):
if cmd == "reregister_cli":
self.register()
return
if cmd != "cli_cmd":
return
cmd = keywords["command"]
args = keywords["args"]
if cmd == ["set", "target"]:
self.target = args[0]
self.send_muc("ok, my lord")
elif cmd == ["kill", "it"]:
if not self.target is None:
self.kick(self.target, "Headshot!")
self.target = None
else:
self.send_muc("no target.")