Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.219.236.62] |
|
Сообщ.
#1
,
|
|
|
Добрый день. в программировании новичек, помидорами прошу не забрасывать.
Собственно telepot На кнопку бот должен отсылать в группу команду /ring, но не отрабатывает условие. Прошу направить на путь истенный. т.к я на 100% уверен что что-то не так делаю import time import datetime import telepot import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD) GPIO.setup(16,GPIO.IN) def handle(msg): chat_id = msg['chat']['id'] command = msg['text'] print('Got command: %s' % command) if GPIO.input(16) == 1: bot.sendMessage(chat_id, str('/ring)')) time.sleep(3) elif command == '/status': bot.sendMessage(chat_id, str('online')) elif command == '/open': bot.sendMessage(chat_id, str('moving')) elif command == '/time': bot.sendMessage(chat_id, str(datetime.datetime.now())) bot = telepot.Bot('*********') bot.message_loop(handle) print('I am listening ...') while 1: time.sleep(10) работает все кроме if GPIO.input(16) == 1: bot.sendMessage(chat_id, str('/ring)')) time.sleep(3) |