evilhero / mylar

An automated Comic Book downloader (cbr/cbz) for use with SABnzbd, NZBGet and torrents
GNU General Public License v3.0
976 stars 172 forks source link

Telegram notification don't work #1637

Closed Bart274 closed 3 years ago

Bart274 commented 7 years ago

Hi,

Can you please check the Telegram again please? It's been a while since I used Mylar, because of personal issues after I have created the PR. I have enabled the Telegram notifications and let it send a test notification. This arrives on my Telegram account without any issue. However, Mylar is snatching comics and I never get a notification, neither for the snatch or for the completed files. The post processing happens by Mylar without an issue, but I don't get notifications.

Thanks in advance.

evilhero commented 7 years ago

I don't use telegram so I'll have to code dive in on this one. I'll see what I can figure out and give a shout back...

Bart274 commented 7 years ago

Thanks, I really appreciate it :)

evilhero commented 7 years ago

Ok, fix is in development now - it took me way longer than humanly possible to figure out how to just set up a bot for sending to...but I figured that part out and then was able to test.

So I'm not sure if it was the fact that it wasn't verifying the https connection, or coupled with the fact that the logging statement had an invalid format to it (at least what I'm used to seeing). So fixed both, tested it and got notified on snatch & on post-processing of test item.

I can add in something to detect the user_id automatically, assuming that it's the only bot available (well I think I can), but if there's more than one bot then it wouldn't know the chat_id information.

For reference, nothing worked until I was able to submit this in an http browser to view the json and retrieve the chat_id session required: https://api.telegram.org/bot<bot_token>/getUpdates Using the above you can get the chat_id under [chat]['id']

Note that I'm not saying that you didn't do that or know of this - but I'm putting it here for my own reference in case something happens with the telegram api again ;)

Bart274 commented 7 years ago

@evilhero thanks a lot! I'll update immediately and will report back 😉

Bart274 commented 7 years ago

@evilhero just noticed Mylar found a new comic, didn't send a notification when it was postprocessed :-(

it also appears that it will always remove the 'notify on snatch' for telegram as well :-(

Bart274 commented 7 years ago

image

Bart274 commented 7 years ago

strangely enough, the log says the notification is sent, but nothing appears

when I use 'test notification' I do get my message though :-(

evilhero commented 7 years ago

You need to save the config and restart mylar for the settings to be applied... Test connection will test the values that are loaded (meaning it won't take any changes in the config until after a save).

Try enabling verbose mode too and doing the connection... Once I got the chat_id correct I didn't have any problems receiving notifications.

hubbcaps commented 7 years ago

Just want to report I'm also receiving the same exact issue. I've also looked over all the code related to telegram and it looks absolutely spot on so I have no idea where the disconnect is. I get the test message fine, just doesn't report on Snatch or Process of any issues.

I'll dig into this some more this week and see if I can't figure out where it's breaking.

Bart274 commented 7 years ago

I'm glad it's not just me, but it's odd we're having issues :(

evilhero commented 7 years ago

Mylar won't notify during manual post-processing unless they were torrent snatches and you have the torrent notify option enabled (it's on the same page as the notifications in the GUI, just under miscellaneous).

If you're using torrents, then I'd need to know the client being used (to look into the snatch notifications)

Bart274 commented 7 years ago

image @evilhero I only have these options.

I'm using the BlackHole method as there is no way to verify the uTorrent connection is working, like it does for sabnzbd

evilhero commented 7 years ago

Yeah this is weird, my test connection is failing now - but I'm receiving notifications for post-processing being completed via nzbs, but not for on snatches....

EDIT. Ok, I found a straggler of sorts - the telegram_onsnatch variable was being referenced everywhere and used, but it was never globally initialized so it would never retain the value. Fixed that, and now I'm getting on snatches in addition to the post-processing and test connections.

I'll have to push these out to dev so you guys can test them, but they seem to work fine for me now with these changes (note that you have to save the config and restart mylar for the test connection option to use the right settings for your telegram if you've changed them in the least - I'll fix this soon so that it will take the live data instead of cached for testing).

Also, have you just tried the uTorrent as a client within Mylar in lieu of the watchdir - just because you can't verify the connection doesn't mean it won't work ;)

Bart274 commented 7 years ago

Odd, and when you use torrents? Also another thing I noticed (which is unrelated to this issue) I need to change settings and first restart before I can test them (test for notifications and for sabnzbd)

evilhero commented 7 years ago

Only 2 notifications have been done that allow you to use the live settings as opposed to having to first save, and restart mylar and then do a test connection. Currently, NMA & Pushbullet are the only two - the remainder I still have to do, but those are the ones that I had available at the time to test the new logic against.

SAB would be the same way - all of these (SAB, notifications, providers) have to be migrated over to the use live settings method instead of the current method of saving, restarting, and testing (which sucks I know). It's coming - but each method requires a little bit of code + a bunch of testing.

I'm testing the torrent portion right now - are you using anything else in addition to just enabling the notifiers (like an on-snatch script, extra pp-script, etc) ?

Bart274 commented 7 years ago

Can I somehow privately give you the address of my installation? Then you can check yourself?

hashmil commented 6 years ago

Hey so i'm having this issue too were i'm getting:

Error sending test message to telegram

What i have done so far:

On mylar i put in my userid and token, and then hit the 'Test Telegram' button. It just throws the error mentioned above.

I've got the notification bots working perfectly for SickRage and CouchPotato, which run on the same machine.

evilhero commented 6 years ago

Your issue is different than the original poster. Please read his first post - he was getting test connection ok, but not other notifications made. Your post is nothing of the same. It makes things difficult to follow, and I'll just end up forgetting about them thinking they were resolved.

Nothing has changed in the code since this issue, so I would check your settings again to ensure they're correct and or forgo the test button and see if things work anyways.

I'm closing this issue - open a new one if the problem persists if the above doesn't work.

Bart274 commented 6 years ago

@evilhero Why did you close this? My issue still exists...

evilhero commented 6 years ago

I closed it because the issue hasn't been touched in over 8 months as well as someone adding problems to the issue that aren't related to the current problem.

If it's still an issue, I'll reopen it but I don't use telegram so not sure when / if this will get fixed, especially since when I did use it I never had any problems. Maybe @hubbcaps can help with this one if he has some time

MrDemous commented 6 years ago

@evilhero I'm facing the exact same problem as @Bart274 . For the past two months Mylar hasn't been sending any notifications to Telegram on snatch or after post-processing but, when I try a test notification it works just fine.

evilhero commented 6 years ago

@MrDemous , not quite sure when things changed - at one point both test & snatch/pp notifications were working.

I tested briefly on my install, got a traceback error immediately on a snatch. Fixed that in the latest development commit, which should actually address both of your issues (not sure if it would cause an error on post-processing, as it would never get that far since the snatch would have failed due to the notification error - but it didn't fail for me in testing now on latest dev commit).

MrDemous commented 6 years ago

@evilhero I switched to the development branch and notifications are working again. Thanks

Bart274 commented 6 years ago

@evilhero I'm still on the development branch and updated to the latest version. I'm still having the same issue as always: I get a notification when a comic is snatched, but after it's been downloaded, it gets postprocessed, but I don't get a notification from that.

evilhero commented 6 years ago

@Bart274 What's your download method in mylar - torrents / nzbs? Which clients do you have enabled within mylar for your methods? Do the given issues go into a Downloaded status after the post-processing, or do they remain in a Snatched status until you do a Recheck Files/Refresh?

Bart274 commented 6 years ago

@evilhero Here is my current workflow:

The only thing I see now in the SABnzbd settings is the checkbox 'Enable Completed Download Handling', it wasn't checked before, is this a new setting? I never saw it before. I enabled that checkbox now to see if that helps.

evilhero commented 6 years ago

How is it post-processing - comicRN or Folder Monitor? If it's Folder Monitor, you will not get notifications as that's basically manual post-processing against a specific folder.

Completed Download Handling (CDH) will let mylar monitor your download client's queue for completion and then post-processes directly against the result, as opposed to comicRN which is an external script.

There's no reason to be using folder monitor to pp sab/nzbget downloads when it can be done with one of the other options more reliably, and in addition receive notifications upon completion.

Bart274 commented 6 years ago

screenshot from 2018-07-10 08-40-27 screenshot from 2018-07-10 08-40-41 screenshot from 2018-07-10 08-40-57

@evilhero These are my current settings. On my Usenet settings I have played with the 'Enable Completed Download Handling' setting, on the Post Processing settings I have played with both the 'Enable Post-Processing' and the 'Enable Folder Monitoring' settings, but no matter what I did I always got a notification for snatched comics, but never for completed downloads and post processed comics.

evilhero commented 6 years ago

You have your folder monitor set to monitor your sabnzbd download directory. Folder monitor will not notify of non-torrent snatches being completed.

Either disable your folder monitor, and keep CDH enabled. Or keep CDH enabled and change your folder monitor location to something other than c:\move.

There's really nothing to play with - if you disable CDH then it won't monitor your sabnzbd queue. If you disable post-processing then it will not perform any post-processing. Turning on/off CDH and folder monitor would require a restart of mylar to ensure that the background jobs either turn on/off properly.

Bart274 commented 6 years ago

@evilhero I have disabled my folder monitoring and kept the Enable Completed Download Handling and Enable Post-Processing active like you said I should do and I restarted Mylar. After restarting Mylar, I had a lot of comics being found and added to SABnzbd for downloading. I got notified of the snatching. The downloads have been completed, but now they aren't post processed anymore. They remain in my c:\move directory and never get added to Mylar and moved to my O:\Comicrack directory. Any clue?

screenshot from 2018-07-11 08-42-57 screenshot from 2018-07-11 08-43-03

evilhero commented 6 years ago

Did you give Mylar the full API key for sabnzbd, or just the nzb API key? What happens when you click on the Test Connection button for sabnzbd?

Also, debug logs. Need to see debug logs showing the send to sab and anything thereafter (CDH will display stats as it's monitoring, so of you don't see that it's not working as it should)

Bart274 commented 6 years ago

@evilhero as you can see on the screenshots I'm using the right API key I think from SABnzbd and when I hit the test connection button I get 'Successfully verified API key'. I also think everything is well set up in SABnzbd? I have enabled DEBUG logging now and disabled the Folder Monitoring once again, I had re enabled Folder Monitoring as otherwise I didn't get any comic processed. I'll keep track of the log on when a new comic is snatched and downloaded so we can check the logs.

screenshot from 2018-07-11 16-14-29 screenshot from 2018-07-11 16-14-37

Bart274 commented 6 years ago

@evilhero Here is my log: https://pastebin.com/P7zvm8ik I have added a new series for testing purposes. Sheena.-.Queen.of.the.Jungle.006.2018.4.covers.Digital.DR.and.Quinch-Empire and Sheena.-.Queen.of.the.Jungle.007.2018.4.covers.Digital.DR.and.Quinch-Empire have both been downloaded by SABnzbd at the time that the log was valid. But they were never picked up as Downloaded and never got processed.

evilhero commented 6 years ago

I haven't looked at the pastebin yet, what branch / commit of mylar are you running as your screenshot looks like it's running an older version (or maybe Master branch)

Bart274 commented 6 years ago

@evilhero I’m running the latest version of the development branch

6c9fdd89-a4bc-40b4-8f60-42cfba4e2db4

Bart274 commented 6 years ago

e61a85c3-6b02-4292-bb19-e6ee6860708a

evilhero commented 6 years ago

It looks like you're running a non-English version of SABnzbd, which I'm thinking might be contributing to the problem here.

When Mylar monitors the SABnzbd queue for completion, it looks for the word Downloading or Idle to denote that the file has completed in some way. It does this for the first few times, but then it just stops monitoring the queue based on your logs as it never indicates in the log that it's finished (it should say 'File has now downloaded!') I'm guessing that when the job completes the status is changed to the language as indicated in SABnzbd so it will never trigger.

There's an easy way to test this - change your language in the SABnzbd interface to English and try to snatch something again with Mylar. I have a feeling it'll work (again just a guess)

Bart274 commented 6 years ago

@evilhero I switched everything to English and restarted SABnzbd and Mylar. I had several comics being snatched and downloaded but again they weren’t processed afterwards 😞

evilhero commented 6 years ago

What version of SABnzbd are you running ? Do you have any other scripts or anything else running after it downloads that might alter things ?

If you're up-to-date with SABnzbd, you might be better off using the ComicRN script attached to a specific category (ie. comics) in your SABnzbd. The problem is that for some reason it's not even returning the completed status back to Mylar even when it's being queried (you can see the timeleft/eta markers in the logs, but then nothing). At least with the ComicRN, it would run it immediately after it downloads, and do the post-process & notifications and it wouldn't rely on SAB returning any data or having to check it's history).

Bart274 commented 6 years ago

I’m running the latest version of sabnzbd 2.3.4 I’ll try the comicRN way tomorrow and will report back

Bart274 commented 6 years ago

@evilhero thanks for your suggesting. I have setup the comicRN script in SABnzbd and now I finally get my notifications :-)

screenshot from 2018-07-13 09-37-54