Example #1
0
def main():
	matchIds,matches = net.getLiveMatches()
	if matches[0] == "No Match in progress":
		op.popUp("Cricket","No match in progress or scheduled soon",0)
		return
	options = ["Matches:"]
	for elem in matches:
		options.append(elem)
	options.append("Back")

	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		exitApp()

	if optionChosen == len(options)-1 :
		return

	minutes = ip.getMinutes(1)
	if minutes == "":
		main()
		return
	pb = ip.getPB()
	op.popUp("Notification Set","{} every {} minute(s)".format(options[optionChosen],minutes),0)
	app.DICTIONARY["Cricket"].append({"matchId":matchIds[optionChosen-1] , "Teams":options[optionChosen], "Interval":minutes*10 , "Counter":minutes*10 ,"PB":pb})
Example #2
0
def getEvents(site):

	if site == "Hackerearth":
		lis = net.getHackerEvents()
	else:
		lis = net.getOtherEvents(site)

	if len(lis) == 0:
		op.popUp(site,"No Upcoming Challenges",0)
	options = ["Upcoming challenges on {}".format(site)]
	for elem in lis:
		options.append("{:<50} {:<40} {:>20}".format(elem["Title"],"StartTime : "+elem["Start"],"EndTime : "+elem["End"]))
	options.append("Back")
	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		exitApp()
	if optionChosen == len(options)-1 :
		main()
	else:
		minutes = ip.getMinutes(30)
		if minutes == "":
			getEvents(site)
			return
		pb = ip.getPB()
		app.DICTIONARY["Coding"].append({"Title":"{} Challenge".format(site),"Message":options[optionChosen],"Interval":minutes*10,"Counter":minutes*10,"PB":pb})
		op.popUp("Notification Set","For {} every {} minute(s)".format(lis[optionChosen-1]["Title"],minutes),0)
Example #3
0
File: app.py Project: pk16/notify
def main():
	global PBon
	global PBobj
	PB=""
	thread = Thread(target = op.thread_func, args = (t_stop,))
	thread.start()
	while True:
		options = ["Choose one of the following"]
		options.append("Cricket Scores")
		options.append("Coding Contest Updates")
		options.append("Tweets")
		options.append("Custom Notification with user defined frequency")
		options.append("Remove any set notification")
		if(PB == ""):
			options.append("Want Notifications on Your PushBullet Devices? Enter Access Token here.")
			PBon = 0
		else:
			options.append("PushBullet Device Set Up Successfully. Want to remove the Access Token?")
			PBon = 1
		options.append("Quit")
		try:
			optionChosen = ip.getUserInput(options)
		except KeyboardInterrupt:
			exitApp()
		if optionChosen == len(options)-1:
			exitApp()
		if(optionChosen == len(options) -2):
			if(PB == ""):
				PB=ip.inputData("PushBullet","Enter Valid Access Token")
				if PB != "":
					try:
						PBobj=Pushbullet(PB) 
						PBon = 1
						op.popUp("Notify","Successfull Setup",1)
					except Exception as e:
						op.popUp("PushBullet","Wrong Access Token or Network Error\nTry Again",0)
						PB=""
			else:
				op.success()
				PB=""
			continue
		if(optionChosen == 1):
			cricket.main()

		if(optionChosen == 2):
			coding.main()

		if(optionChosen == 3):
			tweet.main()

		if(optionChosen == 4):
			custom.getData()
		
		if(optionChosen == 5):
			remove.main()
Example #4
0
def getTrending(woeid):
    lis = []
    try:
        data = api.trends_place(woeid)
    except Exception as e:
        op.popUp("Error","Can not get the trend. Network Error",0)
        app.main()
    data = data[0]
    trendsData = data["trends"]
    for elem in trendsData:
        lis.append(elem["name"])
    return lis
Example #5
0
File: tweet.py Project: pk16/notify
def getData():
	hashtag = ip.inputData("Hashtag","Enter the hashtag")
	if hashtag == "":
		return
	minutes = ip.getMinutes(1)
	if minutes == "":
		main()
		return
	pb = ip.getPB()
	#IN LIST
	app.DICTIONARY["Tweets"].append({"HashTag":hashtag , "Interval":minutes*10 , "Counter":minutes*10 ,"PB":pb})
	op.popUp("Notification Set","Tweets for \"{}\" every {} minute(s)".format(hashtag,minutes),0)
Example #6
0
def getData():
	title = ip.inputData("Title","Enter the title")
	if title == "":
		return
	msg = ip.inputData("Message","Enter the message for notification")
	if msg == "":
		return
	minutes = ip.getMinutes(10)
	if minutes == "":
		return
	pb = ip.getPB()
	#IN LIST
	app.DICTIONARY["Custom"].append({"Title":title , "Message":msg , "Interval":minutes*10 , "Counter":minutes*10 , "PB":pb})
	op.popUp("Notification Set","For title \"{}\" and message \"{}\" every {} minute(s)".format(title,msg,minutes),0)
Example #7
0
File: tweet.py Project: pk16/notify
def trending(name,woeid):
	options = ["Top 10 {}".format(name)]
	op.popUp("Notify","Fetching Data",0)
	trend = net.getTrending(woeid)
	options = options + trend
	options.append("Back")
	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		exitApp()
	if optionChosen == len(options)-1 :
		main()
	else:
		minutes = ip.getMinutes(1)
		if minutes == "":
			trending(name,woeid)
		app.DICTIONARY["Tweets"].append({"HashTag":options[optionChosen] , "Interval":minutes*10 , "Counter":minutes*10 })
		op.popUp("Notification Set","Tweets for \"{}\" every {} minute(s)".format(options[optionChosen],minutes),0)
Example #8
0
def main():
	options = ["Choose an option"]
	for elem in lis:
		if len(app.DICTIONARY[elem]) != 0 :
			options.append(elem)

	if len(options) == 1:
		op.popUp("Error","No notifications set up",0)
		return

	options.append("Remove all notifications")
	options.append("Back")

	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		t_stop.set()
		exitApp()

	if(optionChosen == len(options)-2):
		for elem in lis:
			del app.DICTIONARY[elem][:]
		op.popUp("Successfull","Removed all notifications",0)

	if(optionChosen == len(options)-1):
		return

	elem = options[optionChosen]

	if elem == lis[0]:
		cricket()

	if elem == lis[1]:
		coding()

	if elem == lis[2]:
		tweet()

	if elem == lis[3]:
		custom()
Example #9
0
def tweet():
	options = ["Following tweets are set"]
	for elem in app.DICTIONARY[lis[2]]:
		options.append("Hashtag \"{}\" with interval of {} minutes".format(elem["HashTag"],elem["Interval"]/10))
	options.append("Remove All")
	options.append("Back")
	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		t_stop.set()
		exitApp()
	if optionChosen == len(options)-1 :
		main()

	elif optionChosen == len(options)-2 :
		del app.DICTIONARY["Tweets"]
		op.popUp("Successfull","Removed all tweet notifications",0)
		return 

	else:
		del app.DICTIONARY["Tweets"][optionChosen-1]
		op.popUp("Successfull","Removed the notification",0)
Example #10
0
def coding():
	options = ["notification for following contests is set"]
	for elem in app.DICTIONARY[lis[1]]:
		options.append(elem["Message"])
	options.append("Remove All")
	options.append("Back")
	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		t_stop.set()
		exitApp()
	if optionChosen == len(options)-1 :
		main()

	elif optionChosen == len(options)-2 :
		del app.DICTIONARY["Coding"]
		op.popUp("Successfull","Removed all coding notifications",0)
		return 

	else:
		del app.DICTIONARY["Coding"][optionChosen-1]
		op.popUp("Successfull","Removed the notification",0)
Example #11
0
def custom():
	options = ["Following custom notifications are set"]
	for elem in app.DICTIONARY[lis[3]]:
		options.append("Title \"{}\", message \"{}\" with interval of {} minutes".format(elem["Title"],elem["Message"],elem["Interval"]/10))
	options.append("Remove All")
	options.append("Back")
	try:
		optionChosen = ip.getUserInput(options)
	except KeyboardInterrupt:
		t_stop.set()
		exitApp()
	if optionChosen == len(options)-1 :
		main()

	elif optionChosen == len(options)-2 :
		del app.DICTIONARY["Custom"]
		op.popUp("Successfull","Removed all custom notifications",0)
		return 

	else:
		del app.DICTIONARY["Custom"][optionChosen-1]
		op.popUp("Successfull","Removed the notification",0)