move url to kwargs, update button action calls for upcoming feature

dev
Thomas Lynch 2 years ago
parent 7a7c2dc4c2
commit 578839a5b5
  1. 19
      components/notifiers.py
  2. 8
      components/watchers.py

@ -4,17 +4,22 @@ from abc import ABC, abstractmethod
class Notifier(ABC):
@abstractmethod
def notify(self, title, content, url, *args, **kwargs):
def notify(self, title, content, *args, **kwargs):
raise NotImplementedError
class TermuxNotifier(Notifier):
def notify(self, title, content, url, *args, **kwargs):
print(url)
subprocess.call(['termux-notification', '--title', title, '--content', content or 'No Message', '--action', 'termux-open-url', url])
def notify(self, title, content, *args, **kwargs):
subprocess.call(['termux-notification', '--title', title,
'--content', content or 'No Message',
'--action', f'termux-open-url {kwargs["url"]}'
'--button1', 'Delete',
'--button1-action', f'python3 notification_button.py -b {kwargs["board"]} -id {kwargs["postId"]} -a delete',
'--button2', 'Ban+Delete',
'--button2-action', f'python3 notificaiton_button.py -b {kwargs["board"]} -id {kwargs["postId"]} -a delete+ban',
'--button3', 'Dismiss',
'--button3-action', f'python3 notification_button.py -b {kwargs["board"]} -id {kwargs["postId"]} -a dismiss'])
class NotifySendNotifier(Notifier):
def notify(self, title, content, url, *args, **kwargs):
print(url)
def notify(self, title, content, *args, **kwargs):
subprocess.call(['notify-send', title, content])

@ -33,17 +33,16 @@ class RecentWatcher(Watcher):
def connect():
logging.debug(f'Live posts client connected')
client.emit('room', f'{board}-manage-recent-hashed' if board else 'globalmanage-recent-hashed')
#notify(f'Connected', f'Watching live posts')
@client.event
def disconnect():
logging.error(f'Live posts client disconnected')
#notify(f'Lost live posts connection', f'Retrying in {reconnection_delay} seconds')
@client.on('newPost')
def on_new_post(post):
board_name = post["board"]
notify(f'Alert! {get_path(post)}\n', post['nomarkup'], f'{session.imageboard_url}/{board_name}/manage/thread/{post["thread"] or post["postId"]}.html#{post["postId"]}')
board_name=post["board"]
post_url=f'{session.imageboard_url}/{board_name}/manage/thread/{post["thread"] or post["postId"]}.html#{post["postId"]}'
notify(f'Alert! {get_path(post)}\n', post['nomarkup'], url=post_url)
self.client = client
self.start()
@ -85,7 +84,6 @@ class ReportsWatcher(Watcher):
except RequestException as e:
logging.error(f'Exception {e} occurred while fetching reports')
#self.notify(f'Error while fetching reports', f'Trying to reconnect')
if self._stp.wait(self.fetch_interval):
logging.info("Exiting reports watcher")

Loading…
Cancel
Save