mirror of
https://github.com/hemna/aprsd-slack-plugin.git
synced 2024-12-04 06:03:11 -05:00
Added some config checking at setup time
This patch ensures we check to make sure the required config keys are available from the aprsd.yml config prior to accessing them. The plugin won't work without them. This prevents the plugin from throwing stack dumps in aprsd.
This commit is contained in:
parent
2f944f703a
commit
b308285b28
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
*.egg-info
|
||||
.tox
|
||||
.idea
|
||||
__pycache__
|
||||
.coverage
|
||||
.coverage.*
|
||||
htmlcov
|
||||
*.pyc
|
||||
docs/_build
|
||||
venv
|
||||
dist
|
||||
.pytest_cache
|
||||
.mypy_cache
|
||||
build
|
@ -1,6 +1,9 @@
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
v1.0.1
|
||||
------
|
||||
|
||||
* remote the pinning of aprsd 1.0.0
|
||||
|
||||
v1.0
|
||||
|
@ -48,15 +48,37 @@ class SlackCommandPlugin(plugin.APRSDPluginBase):
|
||||
"""Create the slack require client from config."""
|
||||
|
||||
# signing_secret = self.config["slack"]["signing_secret"]
|
||||
bot_token = self.config["slack"]["bot_token"]
|
||||
if "slack" not in self.config:
|
||||
LOG.error("APRSD config is missing slack section")
|
||||
return False
|
||||
|
||||
bot_token = self.config["slack"].get("bot_token", None)
|
||||
if not bot_token:
|
||||
LOG.error(
|
||||
"APRSD config is missing slack: bot_token:<token>. "
|
||||
"Please install the slack app and get the "
|
||||
"Bot User OAth Access Token."
|
||||
)
|
||||
return False
|
||||
|
||||
self.swc = WebClient(token=bot_token)
|
||||
|
||||
self.slack_channel = self.config["slack"]["channel"]
|
||||
self.slack_channel = self.config["slack"].get("channel", None)
|
||||
if not self.slack_channel:
|
||||
LOG.error(
|
||||
"APRSD config is missing slack: slack_channel: <name> "
|
||||
"Please add a slack channel name to send messages."
|
||||
)
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def command(self, fromcall, message, ack):
|
||||
LOG.info("SlackCommandPlugin")
|
||||
|
||||
self._setup_slack()
|
||||
is_setup = self._setup_slack()
|
||||
if not is_setup:
|
||||
return
|
||||
|
||||
# now call the location plugin to get the location info
|
||||
location_plugin = plugin.LocationPlugin(self.config)
|
||||
|
Loading…
Reference in New Issue
Block a user