mirror of https://gitgud.io/fatchan/globalafk
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
1.1 KiB
25 lines
1.1 KiB
import subprocess
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class Notifier(ABC):
|
|
@abstractmethod
|
|
def notify(self, title, content, *args, **kwargs):
|
|
raise NotImplementedError
|
|
|
|
|
|
class TermuxNotifier(Notifier):
|
|
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, *args, **kwargs):
|
|
subprocess.call(['notify-send', title, content])
|
|
|