Updated to work with 2.0.0
This commit is contained in:
parent
3ce8471cb0
commit
8bc5afe1ed
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from aprsd import messaging, plugin
|
from aprsd import messaging, packets, plugin
|
||||||
|
|
||||||
import aprsd_slack_plugin
|
import aprsd_slack_plugin
|
||||||
from aprsd_slack_plugin import base_plugin
|
from aprsd_slack_plugin import base_plugin
|
||||||
|
@ -12,35 +12,7 @@ class SlackNotifyPlugin(
|
||||||
base_plugin.SlackPluginBase,
|
base_plugin.SlackPluginBase,
|
||||||
plugin.APRSDNotificationPluginBase,
|
plugin.APRSDNotificationPluginBase,
|
||||||
):
|
):
|
||||||
"""SlackCommandPlugin.
|
"""SlackNotifyPlugin. """
|
||||||
|
|
||||||
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: <signing secret token here>
|
|
||||||
bot_token: <Bot User OAuth Access Token here>
|
|
||||||
channel: <channel name here>
|
|
||||||
"""
|
|
||||||
|
|
||||||
version = aprsd_slack_plugin.__version__
|
version = aprsd_slack_plugin.__version__
|
||||||
|
|
||||||
|
@ -54,23 +26,24 @@ class SlackNotifyPlugin(
|
||||||
if not is_setup:
|
if not is_setup:
|
||||||
return
|
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 = "<http://aprs.fi/info/a/{}|{}>".format(fromcall, fromcall)
|
||||||
|
|
||||||
callsign_url = "<http://aprs.fi/info/a/{}|{}>".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 = {}
|
LOG.debug(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)
|
# self.swc.chat_postMessage(**message)
|
||||||
|
for channel in self.slack_channels:
|
||||||
# self.swc.chat_postMessage(**message)
|
message["channel"] = channel
|
||||||
for channel in self.slack_channels:
|
self.swc.chat_postMessage(**message)
|
||||||
message["channel"] = channel
|
|
||||||
self.swc.chat_postMessage(**message)
|
|
||||||
|
|
||||||
# Don't have aprsd try and send a reply
|
# Don't have aprsd try and send a reply
|
||||||
return messaging.NULL_MESSAGE
|
return messaging.NULL_MESSAGE
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pbr
|
pbr
|
||||||
slack_sdk>=3.0
|
slack_sdk>=3.0
|
||||||
slackeventsapi>=2.1.0
|
slackeventsapi>=2.1.0
|
||||||
aprsd
|
aprsd>=2.0.0
|
||||||
|
|
Loading…
Reference in New Issue