How to use the oncall.run function in oncall

To help you get started, we’ve selected a few oncall examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cbarraford / Oncall / bin / oncall-server.py View on Github external
oncall_status = "Currenty, %s is on call" % (u.name)
							else:
								oncall_status = "Currenty, no one is on call"
						with r.gather(action="%s:%s/call/event?init=false" % (conf['server_address'],conf['port']), timeout=conf['call_timeout'], method="POST", numDigits="1") as g:
							g.say('''Hello %s. %s. Press 1 if you want to hear the present status of alerts. Press 2 to acknowledge the last alert sent to you. Press 3 to conference call everyone on call into this call.''' % (requester.name, oncall_status))
					else:
						with r.gather(action="%s:%s/call/event?init=false" % (conf['server_address'],conf['port']), timeout=conf['call_timeout'], method="POST", numDigits="1") as g:
							g.say('''Press 1 if you want to hear the present status of alerts. Press 2 to acknowledge the last alert sent to you. Press 3 to conference call everyone on call into this call.''')
					r.say(timeout_msg)
				elif int(d.Digits) == 1:
					# getting the status of alerts
					r.say(oncall.run("alert status -f " + requester.phone))
					r.redirect(url="%s:%s/call/event?init=false" % (conf['server_address'],conf['port']))
				elif int(d.Digits) == 2:
					# acking the last alert sent to the user calling
					r.say(oncall.run("alert ack -f " + requester.phone))
					r.redirect(url="%s:%s/call/event?init=false" % (conf['server_address'],conf['port']))
				elif int(d.Digits) == 3:
					# calling the other users on call
					oncall_users_raw = User.on_call(requester.team)
					for user in oncall_users_raw:
						if user.phone == requester.phone: continue
						r.say("Calling %s." % user.name)
						r.dial(number=user.phone)
				else:
					r.say("Sorry, number you pressed is not valid. Please try again.")
		return r
github cbarraford / Oncall / bin / oncall-server.py View on Github external
def POST(self,name):
		d = web.input()
		logging.info("Receiving SMS message\n%s" % (d))
		# incoming text message, handle it
		web.header('Content-Type', 'text/xml')
		r = twilio.twiml.Response()
		user = User.get_user_by_phone(d.From)
		# make sure person sending the text is an authorized user of Oncall
		if user == False:
			logging.error("Unauthorized access attempt via SMS by %s\n%s" % (d.From, d))
			r.sms("You are not a authorized user")
		else:
			# split the output into 160 character segments
			for text_segment in twilio.split_sms(oncall.run(d.Body + " -m -f " + d.From)):
				r.sms(text_segment)
		return r