Skip to content
Snippets Groups Projects
Commit bc9a8f51 authored by wactbprot's avatar wactbprot
Browse files

cmd struct and output

parent 744a430e
Branches
No related tags found
No related merge requests found
...@@ -51,27 +51,41 @@ class Bot(System): ...@@ -51,27 +51,41 @@ class Bot(System):
def handle_command(self, command, channel): def handle_command(self, command, channel):
default_response = "Not sure what you mean.\n Try *gas?* or *calids?*." ok = False
response = None
if command == 'gas?': if command.startswith('ga'):
response = "calibration gas is {}".format(self.aget('gas',0)) ok = True
self.post(channel, "calibration gas is {}".format(self.aget('gas',0)))
if command == "calids?": if command.startswith('id'):
ids ="" ok = True
self.post(channel, "doc ids are:")
lines = self.get_lines("cal_id") lines = self.get_lines("cal_id")
for line in lines: for line in lines:
ids += self.aget("cal_id", line) self.post(channel, self.aget("cal_id", line))
if command.startswith('fu'):
ok = True
self.post(channel, "fullscale of the devices are:")
lines = self.get_lines("fullscale_value")
for line in lines:
self.post(channel, "{} {} ".format(self.aget("fullscale_value", line), self.aget("fullscale_unit", line)))
if command.startswith('he'):
ok = True
self.post(channel, "Available command are *he[lp]* *ga[s]*, *fu[llscales]* or *id[s]*.")
response = "documet ids are {}".format(ids) if not ok:
self.post(channel, "Not sure what you mean. Try *help* command.")
def post(self, channel, msg):
self.slack_client.api_call( self.slack_client.api_call(
"chat.postMessage", "chat.postMessage",
channel=self.info_channel_id, channel=channel,
text=response or default_response text=msg
) )
def msg_in(self): def msg_in(self):
self.log.debug("message in") self.log.debug("message in")
...@@ -93,7 +107,7 @@ class Bot(System): ...@@ -93,7 +107,7 @@ class Bot(System):
"chat.postMessage", "chat.postMessage",
channel=self.info_channel_id, channel=self.info_channel_id,
text=item.get('data') text=item.get('data')
) )
else: else:
self.log.error("got no info channel id") self.log.error("got no info channel id")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment