mirror of
https://github.com/evilhero/mylar
synced 2024-12-22 07:42:24 +00:00
send imageurl to notifiers
This commit is contained in:
parent
7df84f51ac
commit
d96265d008
2 changed files with 30 additions and 12 deletions
|
@ -1942,8 +1942,12 @@ class PostProcessor(object):
|
|||
logger.info('%s Post-Processing completed for: [ %s #%s ] %s' % (module, comicname, issuenumber, grab_dst))
|
||||
self._log(u"Post Processing SUCCESSFUL! ")
|
||||
|
||||
imageUrl = myDB.select('SELECT ImageURL from issues WHERE IssueID=?', [issueid])
|
||||
if imageUrl:
|
||||
imageUrl = imageUrl[0][0]
|
||||
|
||||
try:
|
||||
self.sendnotify(comicname, issueyear=None, issuenumOG=issuenumber, annchk=annchk, module=module)
|
||||
self.sendnotify(comicname, issueyear=None, issuenumOG=issuenumber, annchk=annchk, module=module, imageUrl=imageUrl)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -2771,7 +2775,11 @@ class PostProcessor(object):
|
|||
# self.sendnotify(series, issueyear, dispiss, annchk, module)
|
||||
# return self.queue.put(self.valreturn)
|
||||
|
||||
self.sendnotify(series, issueyear, dispiss, annchk, module)
|
||||
imageUrl = myDB.select('SELECT ImageURL from issues WHERE IssueID=?', [issueid])
|
||||
if imageUrl:
|
||||
imageUrl = imageUrl[0][0]
|
||||
|
||||
self.sendnotify(series, issueyear, dispiss, annchk, module, imageUrl)
|
||||
|
||||
logger.info('%s Post-Processing completed for: %s %s' % (module, series, dispiss))
|
||||
self._log(u"Post Processing SUCCESSFUL! ")
|
||||
|
@ -2784,7 +2792,7 @@ class PostProcessor(object):
|
|||
return self.queue.put(self.valreturn)
|
||||
|
||||
|
||||
def sendnotify(self, series, issueyear, issuenumOG, annchk, module):
|
||||
def sendnotify(self, series, issueyear, issuenumOG, annchk, module, imageUrl):
|
||||
|
||||
if issueyear is None:
|
||||
prline = '%s %s' % (series, issuenumOG)
|
||||
|
@ -2812,7 +2820,7 @@ class PostProcessor(object):
|
|||
|
||||
if mylar.CONFIG.TELEGRAM_ENABLED:
|
||||
telegram = notifiers.TELEGRAM()
|
||||
telegram.notify(prline2)
|
||||
telegram.notify(prline2, imageUrl)
|
||||
|
||||
if mylar.CONFIG.SLACK_ENABLED:
|
||||
slack = notifiers.SLACK()
|
||||
|
|
|
@ -340,7 +340,17 @@ class TELEGRAM:
|
|||
else:
|
||||
self.token = test_token
|
||||
|
||||
def notify(self, message):
|
||||
def notify(self, message, imageurl=None):
|
||||
if imageurl:
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'caption': message, 'photo': imageurl}
|
||||
|
||||
# Send message to user using Telegram's Bot API
|
||||
try:
|
||||
response = requests.post(self.TELEGRAM_API % (self.token, "sendPhoto"), json=payload, verify=True)
|
||||
except Exception, e:
|
||||
logger.info(u'Telegram notify failed: ' + str(e))
|
||||
else:
|
||||
# Construct message
|
||||
payload = {'chat_id': self.userid, 'text': message}
|
||||
|
||||
|
|
Loading…
Reference in a new issue