Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telegram.ext import Updater, CommandHandler, MessageHandler, RegexHandler, InlineQueryHandler, Filters
- from datetime import datetime
- from openhab import openHAB
- import os
- updater = Updater('<TOKEN REMOVED>')
- base_url = 'http://10.0.0.116:8080/rest'
- openhab = openHAB(base_url)
- items = openhab.fetch_all_items()
- MasterBedroom = items.get('MasterBedroom')
- LivingRoom = items.get('livingroom')
- all = items.get('all')
- Tv = items.get('Tv')
- now = datetime.now()
- def start(bot, update):
- update.message.reply_text('Hello Starting Bot Config & Loading Database, Hello I Am FrightBot I Run Intel And Relay Player Tracker Data.')
- def date(bot, update):
- update.message.reply_text(
- 'Date: {}/{}/{}'.format(now.month, now.day, now.year))
- def time(bot, update):
- update.message.reply_text(
- 'Time: {}:{}'.format(now.hour, now.minute))
- def boobs(bot, update):
- update.message.reply_text('Excuse Me!! No Need For Boobs Here!!!!')
- def livingstatus(bot, update):
- update.message.reply_text(
- '{}'.format(LivingRoom.state))
- def masterstatus(bot, update):
- update.message.reply_text(
- '{}'.format(MasterBedroom.state))
- def tvstatus(bot, update):
- update.message.reply_text(
- '{}'.format(Tv.state))
- def allstatus(bot, update):
- update.message.reply_text(
- '{}'.format(all.state))
- def tvon(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.0.0.116:8080/rest/items/tv"')
- update.message.reply_text('Turning Tv ON')
- def tvoff(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://10.0.0.116:8080/rest/items$
- update.message.reply_text('Turning Tv OFF')
- def masteron(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.0.0.116:8080/rest/items/masterbedroom"')
- update.message.reply_text('Master Bedroom Lights ON')
- def masteroff(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://10.0.0.116:8080/rest/items/masterbedroom"')
- update.message.reply_text('Master Bedroom Lights OFF')
- def livingon(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "ON" "http://10.0.0.116:8080/rest/items/livingroom"')
- update.message.reply_text('Living Room Lights ON')
- def livingoff(bot, update):
- os.system('curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "OFF" "http://10.0.0.116:8080/rest/items$
- update.message.reply_text('Turning Living Room Lights OFF Current Status:{}'.format(livingroom.state))
- def help(bot, update):
- update.message.reply_text('List Of Commands /start,/date,/time,/boobs,/masterstatus,/masteron,/masteroff,/livingstatus,/livingon,/livingoff$
- def unknown(bot, update):
- bot.sendMessage(chat_id=update.message.chat_id, text="Sorry, I didn't understand that command.")
- updater.dispatcher.add_handler(CommandHandler('allstatus', allstatus))
- updater.dispatcher.add_handler(CommandHandler('help', help))
- updater.dispatcher.add_handler(CommandHandler('livingoff', livingoff))
- updater.dispatcher.add_handler(CommandHandler('livingon', livingon))
- updater.dispatcher.add_handler(CommandHandler('masteroff', masteroff))
- updater.dispatcher.add_handler(CommandHandler('masteron', masteron))
- updater.dispatcher.add_handler(CommandHandler('boobs', boobs))
- updater.dispatcher.add_handler(CommandHandler('start', start))
- updater.dispatcher.add_handler(CommandHandler('date', date))
- updater.dispatcher.add_handler(CommandHandler('time', time))
- updater.dispatcher.add_handler(CommandHandler('livingstatus', livingstatus))
- updater.dispatcher.add_handler(CommandHandler('masterstatus', masterstatus))
- updater.dispatcher.add_handler(CommandHandler('tvstatus', tvstatus))
- updater.dispatcher.add_handler(CommandHandler('tvon', tvon))
- updater.dispatcher.add_handler(CommandHandler('tvoff', tvoff))
- unknown_handler = MessageHandler(Filters.command, unknown)
- dispatcher.add_handler(unknown_handler)
- updater.start_polling()
- updater.idle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement