add .help command
This commit is contained in:
+19
-4
@@ -4,20 +4,22 @@ TBD
|
||||
|
||||
__author__ = "Lukas Mahler"
|
||||
__version__ = "0.0.0"
|
||||
__date__ = "07.10.2021"
|
||||
__date__ = "13.10.2021"
|
||||
__email__ = "m@hler.eu"
|
||||
__status__ = "Development"
|
||||
|
||||
|
||||
# Default
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
import inspect
|
||||
|
||||
# Custom
|
||||
import ts3
|
||||
|
||||
# Self
|
||||
import util
|
||||
from src import util
|
||||
|
||||
|
||||
def follow(self, invkr_id, parameter):
|
||||
@@ -25,7 +27,7 @@ def follow(self, invkr_id, parameter):
|
||||
|
||||
"""
|
||||
|
||||
if not parameter[0]:
|
||||
if not parameter:
|
||||
err = "Please use the command like this: .follow TARGET"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=err)
|
||||
return
|
||||
@@ -35,7 +37,7 @@ def follow(self, invkr_id, parameter):
|
||||
clients = self.bot.clientfind(pattern=target)
|
||||
clids = [client["clid"] for client in clients]
|
||||
if len(clids) == 1:
|
||||
cid = self.bot.clientinfo(clids[0])["cid"]
|
||||
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}")
|
||||
@@ -47,7 +49,20 @@ def follow(self, invkr_id, parameter):
|
||||
return
|
||||
|
||||
|
||||
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)}"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=msg)
|
||||
|
||||
|
||||
def info(self, invkr_id):
|
||||
"""
|
||||
|
||||
"""
|
||||
# TODO implement more then just the runtime
|
||||
msg = f"Runtime: {util.getRuntime(self.started)}"
|
||||
self.bot.sendtextmessage(targetmode=1, target=invkr_id, msg=msg)
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ TBD
|
||||
|
||||
__author__ = "Lukas Mahler"
|
||||
__version__ = "0.0.0"
|
||||
__date__ = "30.09.2021"
|
||||
__date__ = "13.10.2021"
|
||||
__email__ = "m@hler.eu"
|
||||
__status__ = "Development"
|
||||
|
||||
@@ -64,7 +64,7 @@ def getRuntime(started):
|
||||
|
||||
"""
|
||||
elapsed = time.time() - started
|
||||
runtime = str(timedelta(seconds=elapsed))
|
||||
runtime = str(timedelta(seconds=elapsed)).split(".")[0] # ignore Microseconds
|
||||
|
||||
return runtime
|
||||
|
||||
|
||||
Reference in New Issue
Block a user