def push(title="", message="", keys=None): if keys is not None: for key in keys: init(key) Client("").send_message(message, title, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) print "Pushed notification!"
def pushnoti_init(): parser = argparse.ArgumentParser() parser.add_argument("--pushsafer_key", required=True, type=str, help="PushSafer private key") args = parser.parse_args() init(args.pushsafer_key) global __CLIENT __CLIENT = Client("")
def send_push(self, message): try: init(privatekey=conf['keys']['pushsafer']) client = Client("") client.send_message(message=message, title="Found", device='a', sound="1", icon="20", vibration="2", answer=0, picture1=None, picture2=None, picture3=None, expire=None, time2live=None, url="", retry=None, urltitle=None, priority=5) print("Push notification has been send") except Exception as e: print(Fore.RED + str(e) + Fore.RESET)
def __init__(self, dc_list): init("qQUde1zemdqdV5iZFACz") self.dc_list = dc_list time_to_dc = self.next_dc() - datetime.now() time_to_dc = divmod(time_to_dc.seconds, 60)[0] if 30 < time_to_dc <= 60 and not Alarm.sixty_played: self.push_notification(60) Alarm.reset_played_status() Alarm.sixty_played = True elif 5 < time_to_dc <= 30 and not Alarm.thirty_played: self.push_notification(30) Alarm.reset_played_status() Alarm.thirty_played = True elif 0 < time_to_dc <= 5 and not Alarm.five_played: self.push_notification(5) Alarm.reset_played_status() Alarm.five_played = True
def send_push_nachricht(message: str, pushsafer_code: str, title: str = "Termin Verfuegbar!"): """Sendet mithilfe von Pushsafer eine Nachricht Args: message (str): Nachricht die in der App angezeigt werden soll pushsafer_code (str): Key fuer das Profil title (str, optional): Titel der Nachricht. Defaults to "Termin Verfuegbar!". """ # all device = "a" # Alarm icon = 2 # Buzzer sound = 8 # 3mal vibration = 3 # nicht automatisch loeschen ttl = 0 # Hoechste priority = 2 # nach 60 erneut senden bis gesehen oder expire in sec retry = 60 # stoppen erneutes zustellen in sec expire = 60 # nicht antworten koennen answer = 0 url = "" url_title = "" image1 = "" image2 = "" image3 = "" pushsafer.init(pushsafer_code) pushsafer.Client().send_message(message, title, device, icon, sound, vibration, url, url_title, ttl, priority, retry, expire, answer, image1, image2, image3)
metavar=('answer'), type=str, help='1 = Answer is possible, 0 = Answer is not possible.') # Argument processing args = parser.parse_args() privatekey = args.privatekey subject = args.subject message = args.message device = args.device icon = args.icon sound = args.sound vibration = args.vibration url = args.url urltitle = args.urltitle time2live = args.time2live priority = args.priority retry = args.retry expire = args.expire answer = args.answer # Try to send the notification init(privatekey) Client("").send_message(message, subject, device, icon, sound, vibration, url, urltitle, time2live, priority, retry, expire, answer, "", "", "") # Exit with success l("Success: Message sent with Private Key [%s]: " % (privatekey)) sys.exit(0)
MT_REQUIRED_TEMP_CHANGED = 5 # send max. every 5min MT_TEMP_OUTSIDE = 6 # send at 0700 and 0730 AM MT_ALL_LIGHTS_OFF = 7 # send at 0900 AM in case of event MT_ISMCS_DOWN = 8 MT_ISMCSGIS_DOWN = 9 # Pushsafer configuration # secure ID HbsZo1UgOxna4oRPfn7x # iPhone7 deviceId 9209 # groupID IPHONE7 = 9209 # init pushsafer API init("HbsZo1UgOxna4oRPfn7x") pushsafer = Client("") # sentMessages stores key-value pairs where key is the message type and value is the time a message of that type was sent # this collection is used to limit sent messages sentMessages = {} def getHeatingOnHours(status): if (status['heating']['value'] == 'OFF'): return 0 if (status['heating']['value'] == None): return 0 since = parser.parse(status['heating']['since']) now = datetime.now(tzutc()) return (now - since).seconds / 3600
if (dHavg < 0) and (DRY_H < H1): remainTime = (DRY_H - H1) / dHavg * PERIOD else: # if dHaverage > 0 then we do not update the remaining time pass else: # There is not enough data to calculate the remainTime remainTime = None if running and dry and not notificationFlag: logger.info("The clothes are dry: sending notification") elapsed_time = time.time() - startTime ets = time.strftime("%H:%M:%S", time.gmtime(elapsed_time)) # Send notification init(pushKey) pushMsg = "Elapsed time : " + ets + "\n" + \ "Now {:.2f} C {:.2f} %RH\n".format(T1, H1) + \ "Delta {:.2f} C {:.2f} %RH".format(dT, dH) Client("").send_message(message=pushMsg, title="Clothes are dry", device=pushDeviceID, icon="62", sound="1", vibration="2", url="", urltitle="", time2live="0", picture1="", picture2="", picture3="")
def rlb(thing): """ Return thing with line breaks replaced by spaces """ return thing.replace("\r", " ").replace("\n", " ") # # Main code # # Arguments parser parser = argparse.ArgumentParser(description='Send Zabbix notification to Pushsafer') parser.add_argument('privatekey', metavar=('Private or Alias Key'), type=str, help='Pushsafer Private or Alias Key') parser.add_argument('subject', metavar=('Subject'), type=str, help='Subject you want to push to the device(s).') parser.add_argument('message', metavar=('Message'), type=str, help='Message you want to push to the device(s).') # Argument processing args = parser.parse_args() privatekey = args.privatekey subject = args.subject message = args.message # Try to send the notification init(privatekey) Client("").send_message(message, subject, "", "", "", "", "", "", "", "", "", "", "", "", "", "") # Exit with success l("Success: Message sent with Private Key [%s]: " % (privatekey)) sys.exit(0)
url = 'https://hackmit.org/' string_watch = "<!-- nice attempt, but puzzle isn't up yet -->" update_time = 60 event_fire_attempt = 0 event_fired = False while not event_fired: res = requests.get(url) event_fire_attempt = event_fire_attempt + 1 if not res.status_code == 200: print_wtime('failed to retrieve webpage (' + str(res.status_code) + ')... attempt #' + str(event_fire_attempt)) time.sleep(update_time) elif not string_watch in res.text: print_wtime('Event Fired: String detected at ' + url) event_fired = True init("9pF4clfsIC4DQGrQQgul") Client("").send_message("A puzzle has ben uploaded to HackMIT!", "Event Fired!", "17746", "26", "5", "3", "https://hackmit.org/", "HackMIT", "0", "1", "120", "1200", "0", "", "", "") else: print_wtime('no state change detected... attempt #' + str(event_fire_attempt)) time.sleep(update_time)
import logging import os import re import requests import sys from bs4 import BeautifulSoup from pushsafer import init, Client from time import sleep init(os.environ.get("PRIVATE_KEY")) pushClient = Client("iPhone") pattern = re.compile('"inventory_quantity":[0-999999]') url = "https://store.ui.com/collections/unifi-protect-cameras/products/uvc-g4-doorbell" logger = logging.getLogger() handler = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s %(name)-12s %(levelname)-8s %(message)s') handler.setFormatter(formatter) logger.addHandler(handler) logger.setLevel(logging.INFO) class BadResponseException(Exception): pass def check_inventory(): resp = requests.get(url) if resp.status_code != 200: logger.info("Did not get a valid response from unifi, exiting")
# name='', # version='', # packages=, # url='', # license='', # author='', # author_email='', # description='' import shutil import os import requests from pushsafer import Client,init url = 'http://nen.duckdns.org/dist/index1.php' url1 = 'https://pushmeapi.jagcesar.se' os.chdir('c:\\Users\\NAMIK\\Desktop\\nenra') shutil.make_archive('nenra','zip','nenra') files = {'file': open('c:\\Users\\NAMIK\\Desktop\\nenra\\nenra.zip', 'rb')} r = requests.post(url, files=files) appnot=" Namık ERDOĞAN saat 18:30 da çıkış yapmıştır" files1 = {'title':appnot,'url':'http://nen.duckdns.org/masa.php','token':'uttju5EvfwKMJHftmlPMtmj2WvYbUZRgScOQBPoGTfQRqZgXsp5UxWOI0GXyoi4t'} r = requests.post(url1,json=files1 ) init("cFZr0FW5Han7YxELPMZb") appnot=" Namık ERDOĞAN saat 18:30 da çıkış yapmıştır" Client("").send_message(appnot, "Bishop", "4274", "1", "4", "2", "https://www.pushsafer.com", "Open Pushsafer", "0", "", "", "")