Esempio n. 1
0
def main():
    print "Token:", token_string
    updater = telegram.Updater(token_string)

    # Get the dispatcher to register handlers
    dp = updater.dispatcher

    # Definisce gli handler di gestione dei comandi
    dp.addTelegramCommandHandler("start", start)
    dp.addTelegramCommandHandler("menu", menu)
    dp.addTelegramCommandHandler("help", menu)

    # on noncommand i.e message - echo the message on Telegram
    dp.addTelegramMessageHandler(echo)

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling(poll_interval=0.1, timeout=10)

    try:
        # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
        # SIGTERM or SIGABRT. This should be used most of the time, since
        # start_polling() is non-blocking and will stop the bot gracefully.
        updater.idle()

    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit
Esempio n. 2
0
def main():	
	print "Token:" , token_string
	updater = telegram.Updater(token_string)	
	
	# Get the dispatcher to register handlers
	dp = updater.dispatcher

	# Definisce gli handler di gestione dei comandi
	dp.addTelegramCommandHandler("start", start)
	dp.addTelegramCommandHandler("menu", menu)
	dp.addTelegramCommandHandler("help", menu)
	
	# on noncommand i.e message - echo the message on Telegram
	dp.addTelegramMessageHandler(echo)

	# log all errors
	dp.addErrorHandler(error)

	# Start the Bot
	update_queue = updater.start_polling(poll_interval=0.1, timeout=10)

	try:  
		# Run the bot until the you presses Ctrl-C or the process receives SIGINT,
		# SIGTERM or SIGABRT. This should be used most of the time, since
		# start_polling() is non-blocking and will stop the bot gracefully.
		updater.idle()

	except KeyboardInterrupt:  
		print "Exit"	
		GPIO.cleanup()       # clean up GPIO on CTRL+C exit  

	GPIO.cleanup()           # clean up GPIO on normal exit  	
Esempio n. 3
0
def main():
    global job_queue

    #@InfraredBot
    updater = telegram.Updater("134968583:AAEXYeTdmbi96qbnqQ3pdBpq3l-4RN8bkMQ")
    job_queue = updater.job_queue

    # Get the dispatcher to register handlers
    dp = updater.dispatcher
    dp.addTelegramCommandHandler("start", start)

    # log all errors
    dp.addErrorHandler(error)

    # Start the Bot
    update_queue = updater.start_polling()

    try:
        # Run the bot until the you presses Ctrl-C or the process receives SIGINT,
        # SIGTERM or SIGABRT. This should be used most of the time, since
        # start_polling() is non-blocking and will stop the bot gracefully.
        updater.idle()

    except KeyboardInterrupt:
        print "Exit"
        GPIO.cleanup()  # clean up GPIO on CTRL+C exit

    GPIO.cleanup()  # clean up GPIO on normal exit
Esempio n. 4
0
def main():	
	global job_queue
	
	#@InfraredBot
	updater = telegram.Updater("134968583:AAEXYeTdmbi96qbnqQ3pdBpq3l-4RN8bkMQ")	
	job_queue = updater.job_queue	

	# Get the dispatcher to register handlers
	dp = updater.dispatcher
	dp.addTelegramCommandHandler("start",start)

	
	# log all errors
	dp.addErrorHandler(error)

	# Start the Bot
	update_queue = updater.start_polling()

	try:  
		# Run the bot until the you presses Ctrl-C or the process receives SIGINT,
		# SIGTERM or SIGABRT. This should be used most of the time, since
		# start_polling() is non-blocking and will stop the bot gracefully.
		updater.idle()

	except KeyboardInterrupt:  
		print "Exit"	
		GPIO.cleanup()       # clean up GPIO on CTRL+C exit  

	GPIO.cleanup()           # clean up GPIO on normal exit  	
Esempio n. 5
0
import acmepins as GPIO
import time
  
GPIO.setmode(GPIO.BOARD)

min = 4
max = 14

#GPIO.setup("J4.34", GPIO.OUT)
 
## Set della frequenza a 50 Herz  (Periodo 20 mS)
servo = GPIO.PWM("J4.34", 50)    

## Imposta il duty cycle al 5% (1 mS on)   
servo.start(min)             

for i in range(10):
	time.sleep(2)

	## Porta il duty cycle al 10% (2 mS on)   
	servo.ChangeDutyCycle(max)   

	time.sleep(2)

	## Porta il duty cycle al 5% (1 mS on)   
	servo.ChangeDutyCycle(min)   
  
servo.stop()
GPIO.cleanup()