From 8bc5afe1edcd6c2910b692ffd1e80c2cb85564dc Mon Sep 17 00:00:00 2001 From: Hemna Date: Sat, 17 Jul 2021 15:35:59 -0400 Subject: [PATCH] Updated to work with 2.0.0 --- aprsd_slack_plugin/notify_plugin.py | 61 ++++++++--------------------- requirements.txt | 2 +- 2 files changed, 18 insertions(+), 45 deletions(-) diff --git a/aprsd_slack_plugin/notify_plugin.py b/aprsd_slack_plugin/notify_plugin.py index 39c33bc..dc2bd44 100644 --- a/aprsd_slack_plugin/notify_plugin.py +++ b/aprsd_slack_plugin/notify_plugin.py @@ -1,6 +1,6 @@ import logging -from aprsd import messaging, plugin +from aprsd import messaging, packets, plugin import aprsd_slack_plugin from aprsd_slack_plugin import base_plugin @@ -12,35 +12,7 @@ class SlackNotifyPlugin( base_plugin.SlackPluginBase, plugin.APRSDNotificationPluginBase, ): - """SlackCommandPlugin. - - This APRSD plugin looks for the location command comming in - to aprsd, then fetches the caller's location, and then reports - that location string to the configured slack channel. - - To use this: - Create a slack bot for your workspace at api.slack.com. - A good source of information on how to create the app - and the tokens and permissions and install the app in your - workspace is here: - - https://api.slack.com/start/building/bolt-python - - - You will need the signing secret from the - Basic Information -> App Credentials form. - You will also need the Bot User OAuth Access Token from - OAuth & Permissions -> OAuth Tokens for Your Team -> - Bot User OAuth Access Token. - - Install the app/bot into your workspace. - - Edit your ~/.config/aprsd/aprsd.yml and add the section - slack: - signing_secret: - bot_token: - channel: - """ + """SlackNotifyPlugin. """ version = aprsd_slack_plugin.__version__ @@ -54,23 +26,24 @@ class SlackNotifyPlugin( if not is_setup: return - # get last location of a callsign, get descriptive name from weather service + wl = packets.WatchList() + if wl.is_old(packet["from"]): + # get last location of a callsign, get descriptive name from weather service + callsign_url = "".format(fromcall, fromcall) - callsign_url = "".format(fromcall, fromcall) + message = {} + message["username"] = "APRSD - Slack Notification Plugin" + message["icon_emoji"] = ":satellite_antenna:" + message["attachments"] = [{}] + message["text"] = "{} - Is now on APRS".format(callsign_url) + message["channel"] = "#hemna" - message = {} - message["username"] = "APRSD - Slack Notification Plugin" - message["icon_emoji"] = ":satellite_antenna:" - message["attachments"] = [{}] - message["text"] = "{} - Is now on APRS".format(callsign_url) - message["channel"] = "#hemna" + LOG.debug(message) - LOG.debug(message) - - # self.swc.chat_postMessage(**message) - for channel in self.slack_channels: - message["channel"] = channel - self.swc.chat_postMessage(**message) + # self.swc.chat_postMessage(**message) + for channel in self.slack_channels: + message["channel"] = channel + self.swc.chat_postMessage(**message) # Don't have aprsd try and send a reply return messaging.NULL_MESSAGE diff --git a/requirements.txt b/requirements.txt index f9e7fff..3e9bfcf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ pbr slack_sdk>=3.0 slackeventsapi>=2.1.0 -aprsd +aprsd>=2.0.0