caronc / nzb-notify

Push Notifications to a large number of supported services for NZBGet and SABnzbd (based on Apprise)
GNU General Public License v3.0
129 stars 15 forks source link

Request: Twitter notifications #31

Closed drizzt09 closed 6 years ago

drizzt09 commented 6 years ago

I used to use a twitter notification setup from this url https://forums.sabnzbd.org/viewtopic.php?f=9&t=17999&p=98578&hilit=twitter#p98578 but this past week it has stopped working with error: Notification script returned exit code 255 and output " C:\Program Files\SABnzbd>CLS C:\Program Files\SABnzbd>SET status= C:\Program Files\SABnzbd>SET zero=0 C:\Program Files\SABnzbd>SET filename="Test Notification" 0 was unexpected at this time. C:\Program Files\SABnzbd>IF EQU 0 (GOTO :SUCCESS) ELSE (GOTO :FAIL) " Would be excellent if your awesome notify service could include twitter

caronc commented 6 years ago

I'll see how difficult it is and hopefully have a look at it this weekend. Since Twitter restricts you to 140 characters or less. Space is somewhat very limited, what did you want to be displayed inside the tweet?

drizzt09 commented 6 years ago

Successful or failed download and file name. I had it DM from 1 twitter account to another twitter account. DM do not have character limits. Also regular tweets are in the process of increasing to 280 characters. Started rolling out last week on a staged roll out. Another option is supporting zapier. It is designed to connect apps. If you can hook into zapier, zapier can fees twitter (and thousands of other apps)

caronc commented 6 years ago

Thanks for your feedback! So do you think this new enhancement should provide both public tweets and DMs, or just DMs?

I'm thinking just private DMs might be the best way to go? What are your thoughts?

Meanwhile I'll investigate zapier (as you mentioned) and other frameworks and see what can be put together.

drizzt09 commented 6 years ago

I personally prefer DM but having two command strings (one for each) would give user options which options are always great. We use Zapier at work to take specific emails and post to Ryver (Slack competitor). You get 5 zaps in a free account

caronc commented 6 years ago

I think i just completed the task! :smile:. Have a go at the master branch and let me know how it goes.

The syntax is: tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/

This is presuming you set up yourself an app correctly on https://apps.twitter.com and generated you a set of Access Tokens!

I was able to send myself a Direct Message (i have not added public tweets yet). If i do implement it, the syntax will be the same, but you'll add ?public=True to the end of the URL.

At this point, I'll just be curious to hear your feedback!

drizzt09 commented 6 years ago

wow that was fast. thanks. OK, created my app and got all keys needed downloaded and extracted master branch into scripts folder selected notify.py and put in the parameters based on the above string with my own info saved but when running test get error: Notification script returned exit code 1 and output "'python' is not recognized as an internal or external command, operable program or batch file. "

Question is the section for "user@". Is it supposed to be replaced with "@user" or just "user" and is it sending user or receiving user?

caronc commented 6 years ago

For SABnzbd you want to choose the special wrapper script (sabnzbd-notify.py); but Notify.py and the Notify directory both need to be present too (all in the same directory).

Then when you fill out the Notification argument, you'll need to put tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/ in the field. You'll need to substituting all the values with what you got from Twitter.

The user can be your twitter identifier (without the @ symbol in front of it) or it can be the Owner Identifier which you can find out from the same screen your Keys are located at. I realize this seems backwards for twitter, but it's actually the correct syntax for a web page URIs.

If you have access to a terminal, you can change to the directory/of/sabnzb/scripts/ and type:

# Test your command manually (without SABnzbd)
python Notify.py -s tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/

# Or, do the same command with the -D switch to see more debugging information that
# may or may not help you, but it may help me (if you belive the problem is still in the script)
python Notify.py -D -s tweet://user@/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/
drizzt09 commented 6 years ago

fixed the script, selection, changed the user which i had a different user. Now i have the user that belongs to the keys. I used CMD in Windows to run your command but get error there too (which i assume is because im on Windows?): 'python' is not recognized as an internal or external command, operable program or batch file.

caronc commented 6 years ago

Weird, SABnzbd relies on Python, does it not? You could make sure it's a part of your Windows installation; get it here. Then giver another go! :)

drizzt09 commented 6 years ago

ok, python installed. python install directory added to windows path. now python recognized in CMD. Running your command gives a different error now. a bunch of lines with my keys and then ends with: 2017-10-05 22:55:09,496 - 9124 - ERROR - Could not initialize tweet instance. 2017-10-05 22:55:09,513 - 9124 - DEBUG - Initialization Exception: No user was specified. 2017-10-05 22:55:09,513 - 9124 - DEBUG - Exiting with return code: 0

But i had python Notify.py -D -s tweet://sickbeard9/key/secret/key/secret

drizzt09 commented 6 years ago

Server parsed to: {'host': 'sickbeard9', 'user': None, 'query': None, 'url': 'tweet://sickbeard9/ is the user going into the wrong field? seems like it thinks the user is the host and the user is blank

drizzt09 commented 6 years ago

I restarted the PC and test passed in Sab, but nothing arrived in Twitter. I ran an actual download and automated the script and got this: 2017-10-06 00:10:52,345 - sabnzbd-notify - 6976 - ERROR - Invalid specified (argument 1) Syntax: sabnzbd-notify.py <Message> url1[,url2[,urlN]]</p> <ul> <li>The <Type> can be one of the following: complete: Job Finished startup: Startup/Shutdown warning: Warning download: Added NZB queue_done: Queue Finished disk_full: Disk Full pp: Post-Processing Started new_login: User Logged In failed: Job Failed other: Other Messages error: Error</li> <li>The <Title> and <Message> are self explanitory. If the <Title> is however left blank, then the description of the <Type> is used instead.</li> <li>All remaining arguments are treated as URLs. You can also delimit multiple URLs in a single string/argument with the use of a comma (,).</li> </ul> <p>but same error as before from CMD: 2017-10-06 00:16:38,447 - 5876 - DEBUG - Server parsed to: {'host': 'sickbeard9', 'user': None, 'query': None, 'url': 'tweet://sickbeard9/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'path': '/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'fullpath': '/ConsumerKey/ConsumerSecret/AccessTokenKey/AccessTokenSecret/', 'password': None, 'port': None, 'qsd': {}, 'schema': 'tweet'} 2017-10-06 00:16:38,447 - 5876 - ERROR - Could not initialize tweet instance. 2017-10-06 00:16:38,447 - 5876 - DEBUG - Initialization Exception: No user was specified. 2017-10-06 00:16:38,447 - 5876 - DEBUG - Exiting with return code: 0</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/caronc"><img src="https://avatars.githubusercontent.com/u/850374?v=4" />caronc</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <blockquote> <p>But i had python Notify.py -D -s tweet://sickbeard9/key/secret/key/secret</p> </blockquote> <p>Your problem is here. Try this instead</p> <pre><code class="language-bash"># Note that the user you dm (sickbeard9 in this case) # must have an @ symbol following it, not a slash (/) Notify.py -D -s tweet://sickbeard9@key/secret/key/secret</code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/drizzt09"><img src="https://avatars.githubusercontent.com/u/6366965?v=4" />drizzt09</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>Thanks. Made the switch. Passed all tests. Will know for sure once something downloads. </p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/drizzt09"><img src="https://avatars.githubusercontent.com/u/6366965?v=4" />drizzt09</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>ok downloads work, get the DM successfully. everything in Sab completes but it gives an error even though it worked. Looks like Sab is complaining about the format? 2017-10-06 20:44:23,622 - <strong>sabnzbd-notify - 5980 - ERROR - Invalid <Type> specified (argument 1)</strong> Syntax: sabnzbd-notify.py <Type> <Title> <Message> url1[,url2[,urlN]]</p> <ul> <li>The <Type> can be one of the following: complete: Job Finished startup: Startup/Shutdown warning: Warning download: Added NZB queue_done: Queue Finished disk_full: Disk Full pp: Post-Processing Started new_login: User Logged In failed: Job Failed other: Other Messages error: Error</li> <li>The <Title> and <Message> are self explanitory. If the <Title> is however left blank, then the description of the <Type> is used instead.</li> <li>All remaining arguments are treated as URLs. You can also delimit multiple <strong>URLs in a single string/argument with the use of a comma (,).</strong></li> </ul> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/caronc"><img src="https://avatars.githubusercontent.com/u/850374?v=4" />caronc</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>Hmm, this is really weird... so first it works... but then it spits out an error that it didn't 😕 </p> <p>What version of SABnzbd are you using? 2.3.0?</p> <p>What do you have in the other Notify.py fields? Perhaps you have a space somewhere or more content in your Arguments entry? It accepts more then one (so you can notify more then 1 thing) if you just keep adding more urls. Perhaps there is a bad url at the end?</p> <p>I might need more time to figure this out because you have me scratching my head. Hopefully I'll have figured it out sometime this weekend. Do you have any other details you can throw at me while i try to reproduce this? Anything at all is useful at this point...</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/drizzt09"><img src="https://avatars.githubusercontent.com/u/6366965?v=4" />drizzt09</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>I have no other strings in that parameter field. I will check for spaces at beginning or end but it looks like it's complaining about a comma which ibdont have. I have all other notification options off. Only have complete and failed downloads checked. Yes version 2.3 64bit. On win10</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/caronc"><img src="https://avatars.githubusercontent.com/u/850374?v=4" />caronc</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>I'm unable to reproduce your problem at all. I keep getting all of the notifications as expected (just like you said you are). But the difference is, I don't see any errors in my logs. ☹️ </p> <p>One thing you could do is:</p> <ol> <li>Capture your logs that surround the error.</li> <li>Let the awesome people in the <a href="https://forums.sabnzbd.org/">SABnzbd forum</a> know what's going on.</li> </ol> <p>The fact that the main notifications are working tells me that SABnzbd just isn't passing in the correct parameters for some strange scenario. I have to assume that your logs have a lot of successful notification messages surrounding the one your inquiring about?</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/drizzt09"><img src="https://avatars.githubusercontent.com/u/6366965?v=4" />drizzt09</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>thanks for the help and it has been working perfectly since. I finally got around to adding a post in Sab forums <a href="https://forums.sabnzbd.org/viewtopic.php?f=9&t=23022">https://forums.sabnzbd.org/viewtopic.php?f=9&t=23022</a> Busy here with Canadian thanksgiving</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/caronc"><img src="https://avatars.githubusercontent.com/u/850374?v=4" />caronc</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>I'm from Canada too! Happy Thanksgiving! :smile:</p> <p>I'm going to close off this ticket now. Feel free to reopen it or create another if you have any more questions or issues!</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/drizzt09"><img src="https://avatars.githubusercontent.com/u/6366965?v=4" />drizzt09</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>solved the issue on the SAb forums. I had set NZB-notify both as a post processing script and as a notification script. post was the one it was failing on.</p> <p>Did you look into Zapier? <a href="https://zapier.com/app/explore">https://zapier.com/app/explore</a></p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/caronc"><img src="https://avatars.githubusercontent.com/u/850374?v=4" />caronc</a> commented <strong> 6 years ago</strong> </div> <div class="markdown-body"> <p>Briefly, i ended up solving your request using another library that gives you unlimited posts to Twitter. But i did check Zapier out! It looks like they have lots of apps they can plug you into!</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>