def acceptrequest(self): try: psinque = self._getPsinqueByKey() except AjaxError: self.displayMessage("templates/Message_PsinqueNotFound.html") return contactIn = self._getContactForIncoming(psinque) contactOut = self._getContactForOutgoing(psinque) if contactOut is None: contactOut = Contact( parent=self.userProfile, friend=contactIn.parent(), friendsContact=contactIn, group=self.userProfile.defaultGroup, persona=self.userProfile.defaultPersona, ) contactOut.put() contactIn.friendsContact = contactOut if not contactOut.outgoing is None: raise AjaxError("There already is a psinque from this user") existingPsinque = contactIn.incoming if not existingPsinque is None: if existingPsinque.private: psinque.delete() raise AjaxError("There already is a private psinque from this user") else: existingPsinque.delete() contactIn.incoming = psinque contactIn.status = "private" contactIn.persona = contactIn.parent().defaultPersona contactIn.put() contactOut.outgoing = psinque contactOut.status = "private" contactOut.persona = contactOut.parent().defaultPersona contactOut.put() psinque.status = "established" psinque.persona = psinque.fromUser.defaultPersona psinque.put() Notifications.notifyAcceptedRequest(psinque) if self.request.get("email") == "true": self.displayMessage( "templates/Message_Accepted.html", templateVariables={"friendsName": contactOut.displayName} ) else: self._sendNewContact(contactOut)
def massSending(message): cid = message.chat.id array = notificationID.get(cid) for a in array: try: bot.send_message(a, message.text) except: bot.send_message(cid, Notifications.notificationError(a)) bot.send_message(cid, Notifications.sendComplete()) del notificationID[cid] userStep[cid] = 0
def rejectrequest(self): psinque = self._getPsinqueByKey() psinque.delete() Notifications.notifyRejectedRequest(psinque) if self.request.get("email") == "true": self.displayMessage( "templates/Message_Rejected.html", templateVariables={"friendsName": psinque.displayName} ) else: self.sendJsonOK()
def __init__(self): self.flow_near = None self.flow_out = None self.cl = CommandList() self.config() self.notify = [] self.notify.append(noti.MockObject(self.cfg)) self.notify.append(noti.TelegramChannel(self.cfg)) self.sensors = [] self.sensors.append(sen.Flow()) self.sensors.append(sen.NFC())
def UpdateStatus(game_id,status): LogEvent("Update status of game to " + status) db_path = os.path.join(os.path.abspath(""),"Gamez.db") game_name = "" system = "" sql = "select game_name,system from requested_games where ID='" + game_id + "'" connection = sqlite3.connect(db_path) cursor = connection.cursor() cursor.execute(sql) result = cursor.fetchall() tables = list() for record in result: game_name = str(record[0]) system = str(record[1]) cursor.close() sql = "update requested_games set status='" + status + "' where game_name = '" + game_name.replace("'","''") + "' and system = '" + system + "'" connection = sqlite3.connect(db_path) cursor = connection.cursor() cursor.execute(sql) connection.commit() cursor.close() message = "Gamez Notification: " + system + " Game: " + game_name + " has been " + status appPath = os.path.abspath("") Notifications.HandleNotifications(status,message,appPath) return
def _addRequestToUpgrade(self, contact, friendsProfile): if contact.incoming.private: raise AjaxError("You already have access to private data") # We need to share our own private data first if contact.persona.public: contact.persona = self.userProfile.defaultPersona contact.status = "pending" contact.put() newPsinque = Psinque( parent=contact, fromUser=friendsProfile, private=True, persona=friendsProfile.defaultPersona, status="pending", ) newPsinque.put() Notifications.notifyPendingPsinque(newPsinque)
def changepersona(self): try: contact = Contact.get(self.getRequiredParameter("contact")) except datastore_errors.BadKeyError: raise AjaxError("Contact does not exist") try: persona = Persona.get(self.getRequiredParameter("persona")) except datastore_errors.BadKeyError: raise AjaxError("Persona does not exist") if contact.persona == persona: self.sendJsonOK() return contact.persona = persona contact.put() if persona.public: if contact.outgoing: contact.outgoing.private = False contact.outgoing.put() Notifications.notifyDowngradedPsinque(contact.outgoing) if contact.friendsContact: contact.friendsContact.status = "public" contact.friendsContact.put() if contact.outgoing: contact.outgoing.persona = persona contact.outgoing.put() self.sendJsonOK()
def chatIDNotification(message): cid = message.chat.id notificationID[cid] = message.text.split(" ") bot.send_message(cid, Notifications.notificationNextStep()) userStep[cid] = 4.5
def sendNotifications(message): cid = message.chat.id bot.send_message(cid, Notifications.sendNotification()) userStep[cid] = 4
def chatInformation(message): cid = message.chat.id bot.send_message(cid, Notifications.chatInformation(message)) if message.chat.type != "private": bot.send_message(cid, message.chat.id)
soup = BeautifulSoup(request.text, 'html5lib') # for table in soup.findAll('tbody'): # for rows in table.findAll('tr'): x = 0 for cols in soup.findAll('td'): for cell in cols: if "GB" in cell: x = x + 1 if x == 1: limit = cell.strip() #print ('Monthly limit is ' + limit) elif x == 2: usage = cell.strip() #print ('Current usage is ' +usage) elif x == 3: remain = cell.strip() #print ('Remaining bandwidth is ' + remain) d1 = d0.replace(month = d0.month + 1, day = 04) #print (d1) delta = d1 - d0 #print delta.days Notifications.pushover(message=usage +' of the ' + limit + ' month limit has been used. ' + remain + ' remains for the next ' + str(delta.days) + ' days', token = app_token, user = user_token)
from Cloudflare import * from Notifications import * from NucleiWrapper import * from Report import * from TMOWrapper import * import sys if __name__ == '__main__': if (len(sys.argv) < 2): print("[*] Usage: python3 audit.py your_domain_name.com", file=sys.stderr) exit(1) domain_name = sys.argv[1] notify_bot = Notifications() notify_bot.send_debug_notification("Starting new subdomain audit at " + str(datetime.datetime.now())) print("[*] Starting SDTKO Audit") cloudflare = Cloudflare() data = cloudflare.get_cname_domains(domain_name) print("[*] Running Nuclei Scanner") nuclei_wrapper = NucleiWrapper() nuclei_result = nuclei_wrapper.check_takeover(data) if len(nuclei_result) == 0: print("[*] Nuclei scan completed no results found.") notify_bot.send_debug_notification( "Nuclei scan completed, no results found.") print("[*] Running Takemeon Scanner") tmo_wrapper = TMOWrapper() tmo_result = tmo_wrapper.check_takeover(data)
def send_alarm(raw_data,event_type): print "sending alarm to caregiver" Notifications.sendNotifications_toTwilio('9198154800',"9198154800")
def send_question(raw_data,event_type): #TODO call parse to ask the relevant question print "Asking question to user...." Notifications.sendNotifications_toParse("")
def __init__(self, nick, email, password, rooms): commands = default_commands commands.extend([ CommandUpdate, CommandNotifications, CommandNotify, CommandUnnotify, CommandListTags, CommandAddTag, CommandRemoveTag ]) version_hash = self._get_current_hash() self._bot_header = r'\[[PulseMonitor]' \ '(https://github.com/Charcoal-SE/PulseMonitor) ' + \ version_hash + r'\]' bot = bp.Bot(nick, commands, rooms, [], "stackexchange.com", email, password) bot.add_alias("Halflife") try: with open(bot._storage_prefix + 'redunda_key.txt', 'r') as file_handle: key = file_handle.readlines()[0].rstrip('\n') bot.set_redunda_key(key) bot.add_file_to_sync({ "name": bot._storage_prefix + 'tags.json', "ispickle": False, "at_home": False }) bot.add_file_to_sync({ "name": bot._storage_prefix + 'notifications.json', "ispickle": False, "at_home": False }) bot.redunda_init(bot_version=version_hash) bot.set_redunda_default_callbacks() bot.set_redunda_status(True) except IOError as ioerr: logging.error(str(ioerr)) logging.warn("Bot is not integrated with Redunda.") bot.set_startup_message(self._bot_header + " started on " + bot._location + ".") bot.set_standby_message(self._bot_header + " running on " + bot._location + " shifting to standby.") bot.set_failover_message(self._bot_header + " running on " + bot._location + " received failover.") notifications = Notifications( rooms, bot._storage_prefix + 'notifications.json') tags = TagManager(bot._storage_prefix + 'tags.json') bot._command_manager.notifications = notifications bot._command_manager.tags = tags bot.start() bot.add_privilege_type(1, "owner") bot.set_room_owner_privs_max() roomlist = bot._rooms halflife = HalflifeListener(roomlist[0], roomlist, notifications, bot._command_manager.tags) #deep_smoke = DeepSmokeListener(roomlist[0], roomlist, notifications) halflife.start() #deep_smoke.start() while bot.is_alive: pass halflife.stop()
import Notifications from DailyDigest import run_daily, run_weekly from utils.util import log TAG = 'Space Launch Now' if __name__ == '__main__': log(TAG, "Initializing server...") scheduler = BackgroundScheduler() scheduler.start() log(TAG, "Created background scheduler.") scheduler.add_job(run_daily, trigger='cron', day_of_week='mon-sun', hour=10, minute=30) scheduler.add_job(run_weekly, trigger='cron', day_of_week='fri', hour=12, minute=30) log(TAG, "Added cronjobs to background scheduler.") Notifications.NotificationServer(scheduler).run() log(TAG, "Notification Server started.") try: while True: time.sleep(600) except (KeyboardInterrupt, SystemExit): # Not strictly necessary if daemonic mode is enabled but should be done if possible scheduler.shutdown()
def should_send_alarm(): print "checking response status" status = Notifications.getRespondedStatus() if status==False: send_alarm("", "")