summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2022-01-11 15:57:43 -0500
committerB. Stack <bgstack15@gmail.com>2022-01-11 15:57:43 -0500
commit48b6864f071f9f714a3689ca8a75a690c4e6af2a (patch)
treefcc40de4d075eadd894a0d036d1d35270c7fa8f5
parentadd discord logic and ini example (diff)
downloadsniffa-discord.tar.gz
sniffa-discord.tar.bz2
sniffa-discord.zip
improve documentationdiscord
-rw-r--r--README.md61
-rwxr-xr-xsniffa.py2
2 files changed, 10 insertions, 53 deletions
diff --git a/README.md b/README.md
index 6fd1408..befdb87 100644
--- a/README.md
+++ b/README.md
@@ -5,12 +5,13 @@ sniffa
[sniffa](https://github.com/danielmitterdorfer/sniffa) is a small utility that allows you to watch Discuss forums for keywords.
-Every time it is invoked, it checks for new posts matching the keywords and creates a notification in the Mac OS X notification bar.
+Every time it is invoked, it checks for new posts matching the keywords and creates a notification in the Discord room for the webhook provided in the config file.
# Requirements
* Python 3
* certifi: Install with `yum install python3-certifi` or `pip3 install --user certifi`
+* `pip3 install --user discord`
# Installation
@@ -20,6 +21,10 @@ Ensure that all prerequisites are installed, then copy `sniffa.py` to any direct
sniffa can be used to query multiple Discuss forums. The keywords and the ids of all already seen posts are maintained in a file `~/.sniffa/watch-$(FORUM_NAME).ini`, where `$(FORUM_NAME)` is a name that you can choose to identify this forum.
+If you have a file named `~/.sniffa/watches-aoe2.ini`, run this command:
+
+ ./sniffa.py aoe2
+
## Example
Consider you want to watch for the keywords "Rally" and "JMeter" in the Elastic Discuss forum at https://discuss.elastic.co.
@@ -36,59 +41,9 @@ url = https://discuss.elastic.co
[JMeter]
```
-Now invoke sniffa: ``python3 sniffa.py elastic``. It will load the watches file for the forum named "elastic", check for new posts (which will be a lot at the first time) and show a notice for each of them in the Mac OS X notification bar.
-
-## Automatic regular invocation
-
-Quite likely you don't want to invoke sniffa manually every time you want to check for new posts. Therefore, you can install sniffa as a launch agent.
-
-Create a new file in `~/Library/LaunchAgents/org.github.sniffa.plist` with the following contents:
-
-```plist
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>Label</key>
- <string>org.github.sniffa</string>
-
- <key>ProgramArguments</key>
- <array>
- <string>~/bin/sniffa.py</string>
- <string>elastic</string>
- </array>
-
- <key>Nice</key>
- <integer>1</integer>
-
- <key>StartInterval</key>
- <integer>7200</integer>
-
- <key>RunAtLoad</key>
- <true/>
-
- <key>StandardErrorPath</key>
- <string>~/.sniffa/sniffa-elastic.err.log</string>
-
- <key>StandardOutPath</key>
- <string>~/.sniffa/sniffa-elastic.out.log</string>
-</dict>
-</plist>
-```
-
-Change the paths depending on the install location of sniffa and also your domain parameter.
-
-With this plist file, sniffa will check the Elastic Discuss forum every two hours (7200 seconds) for new posts.
-
-Finally register the launch agent with Mac OS X:
-
-```
-launchctl load ~/Library/LaunchAgents/org.github.sniffa.plist
-```
-
-After a restart, Mac OS X will pick up the plist file automatically.
+Now invoke sniffa: ``./sniffa.py elastic``. It will load the watches file for the forum named "elastic", check for new posts (which will be a lot at the first time) and send an alert to your Discord webhook.
-If you are interested in more details about launch agents, check [Alvin Alexander's blog post about plist files](http://alvinalexander.com/mac-os-x/mac-osx-startup-crontab-launchd-jobs) (on which this description is based).
+See the included `watch-example.ini`.
# License
diff --git a/sniffa.py b/sniffa.py
index 69dd6ae..78334f3 100755
--- a/sniffa.py
+++ b/sniffa.py
@@ -13,6 +13,8 @@
# ./sniffa.py aoe2
# Reference:
# https://meta.discourse.org/t/watching-and-sending-notifications-for-keywords/59286
+# https://stackoverflow.com/questions/62731561/discord-send-message-only-from-python-app-to-discord-channel-one-way-communic/62731999#62731999
+# https://discordpy.readthedocs.io/en/latest/api.html#discord.Webhook.send
# Improve:
# Documentation: See README.md
# Dependencies:
bgstack15