This page is being edited.
This bot tells you who is in your house and what devices are working at the moment. Put the script scan_arp_home.py from the section Smart home knows in the directory with your bot.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
import settings from telegram.ext import * from telegram import * import time from scan_arp_home import scan_arp def report_keyboard(): report_keyboard = [['report the situation at home']] return report_keyboard def start(update, context): if not update.message.chat_id == settings.my_chat_id: return update.message.reply_text("please press the button to find out the situation in your home", reply_markup=ReplyKeyboardMarkup(report_keyboard(), resize_keyboard=True)) def report(update, context): if not update.message.chat_id == settings.my_chat_id: return update.message.reply_text('I need about 20 seconds to get data') situation_at_home = scan_arp() update.message.reply_text(situation_at_home,reply_markup=ReplyKeyboardMarkup(report_keyboard(), resize_keyboard=True)) def main(): updater = Updater(settings.TELEGRAM_API_KEY, use_context=True) dp = updater.dispatcher dp.add_handler(CommandHandler("start", start)) dp.add_handler(MessageHandler(Filters.regex('^report the situation at home'),report)) # Start the Bot updater.start_polling() updater.idle() if __name__ == '__main__': main() |