mute/unmute commands, structual rewrite and ordering
This commit is contained in:
+58
-17
@@ -4,7 +4,7 @@ TBD
|
||||
|
||||
__author__ = "Lukas Mahler"
|
||||
__version__ = "0.0.0"
|
||||
__date__ = "13.10.2021"
|
||||
__date__ = "24.10.2021"
|
||||
__email__ = "m@hler.eu"
|
||||
__status__ = "Development"
|
||||
|
||||
@@ -33,20 +33,9 @@ def follow(self, invkr_id, parameter):
|
||||
return
|
||||
|
||||
target = parameter[0]
|
||||
try:
|
||||
clients = self.bot.clientfind(pattern=target)
|
||||
clids = [client["clid"] for client in clients]
|
||||
if len(clids) == 1:
|
||||
cid = self.bot.clientinfo(clid=int(clids[0]))[0]["cid"]
|
||||
self.bot.clientmove(clid=self.myid, cid=cid)
|
||||
else:
|
||||
self.pipeOut(f"Found multiple matching clients using pattern {target}:{clids}")
|
||||
return
|
||||
|
||||
except ts3.query.TS3QueryError as e:
|
||||
self.pipeOut(f"No client found using pattern {target},"
|
||||
f"returned error:\n{e}", lvl="ERROR")
|
||||
return
|
||||
clid = self.identifytarget(target)
|
||||
cid = self.bot.clientinfo(clid=int(clid))[0]["cid"]
|
||||
self.bot.clientmove(clid=self.myid, cid=cid)
|
||||
|
||||
|
||||
def help(self, invkr_id):
|
||||
@@ -55,7 +44,7 @@ def help(self, invkr_id):
|
||||
"""
|
||||
# Find all functions in this submodule
|
||||
cmds = [f[0] for f in inspect.getmembers(sys.modules[__name__], inspect.isfunction)]
|
||||
msg = f"List of commands:\n{f'{chr(10)}.'.join(cmds)}"
|
||||
msg = f"\n\nList of commands:\n---------------------\n.{f'{chr(10)}.'.join(cmds)}"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=msg)
|
||||
|
||||
|
||||
@@ -64,7 +53,8 @@ def info(self, invkr_id):
|
||||
|
||||
"""
|
||||
# TODO implement more then just the runtime
|
||||
msg = f"Runtime: {util.getRuntime(self.started)}"
|
||||
msg = f"\n\nRuntime: {util.getRuntime(self.started)}\n" \
|
||||
f"Version: {self.version}"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=msg)
|
||||
|
||||
|
||||
@@ -91,12 +81,41 @@ def msglist(self, invkr_id, parameter):
|
||||
mydict[client["client_nickname"]] = {"clid": client["clid"], "cldbid": client["client_database_id"]}
|
||||
mydict = dict(sorted(mydict.items()))
|
||||
msg = json.dumps(mydict)
|
||||
|
||||
elif what == "groups":
|
||||
groups = self.bot.servergrouplist()
|
||||
for group in groups:
|
||||
mydict[group["name"]] = {"sgid": group["sgid"], "sortid": group["sortid"]}
|
||||
msg = json.dumps(mydict)
|
||||
|
||||
else:
|
||||
msg = None
|
||||
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=msg)
|
||||
|
||||
|
||||
def mute(self, invkr_id, parameter):
|
||||
"""
|
||||
Assign the mute group to a user.
|
||||
"""
|
||||
|
||||
if not parameter:
|
||||
err = "Please use the command like this: .mute TARGET"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
|
||||
target = parameter[0]
|
||||
clid = self.identifytarget(target)
|
||||
cldbid = self.clid2cldbid(clid)
|
||||
|
||||
try:
|
||||
self.bot.servergroupaddclient(sgid=self.sgid_mute, cldbid=cldbid)
|
||||
except ts3.query.TS3QueryError as e:
|
||||
err = f"Failed to add to group: [{e}]"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
|
||||
|
||||
def notifyAdmin(self):
|
||||
"""
|
||||
Ping every available admin.
|
||||
@@ -115,5 +134,27 @@ def notifyAdmin(self):
|
||||
time.sleep(1)
|
||||
|
||||
|
||||
def unmute(self, invkr_id, parameter):
|
||||
"""
|
||||
Remove the mute group to a user.
|
||||
"""
|
||||
|
||||
if not parameter:
|
||||
err = "Please use the command like this: .unmute TARGET"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
|
||||
target = parameter[0]
|
||||
clid = self.identifytarget(target)
|
||||
cldbid = self.clid2cldbid(clid)
|
||||
|
||||
try:
|
||||
self.bot.servergroupdelclient(sgid=self.sgid_mute, cldbid=cldbid)
|
||||
except ts3.query.TS3QueryError as e:
|
||||
err = f"Failed to remove from group: [{e}]"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit()
|
||||
|
||||
+3
-2
@@ -7,8 +7,9 @@ sid = 1
|
||||
user = "exampleuser"
|
||||
pwd = "password"
|
||||
|
||||
[Allowed]
|
||||
sgids = ["1"]
|
||||
[Groups]
|
||||
admins = ["1"]
|
||||
mute = "0"
|
||||
|
||||
[Misc]
|
||||
nickname = "myTS3-Bot"
|
||||
|
||||
Reference in New Issue
Block a user