Close

Telegram bot

A project log for Smart Intercom

Real-Time system that allow to pass only authorized/invited people, using Face-Recognition or NFC cards.

evgheniiEvghenii 08/01/2017 at 07:100 Comments

Made telegram bot for Smart Intercom. It sends last pic when buttons is pressed and can open the door.

Face.py

# -*- coding: utf-8 -*-
import config
import telebot
import os
import time
import requests
import subprocess
import simplejson
import sys
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telebot import types
bot = telebot.TeleBot(config.token)
@bot.message_handler(content_types=["text"])
def any_msg(message):
    keyboard = types.InlineKeyboardMarkup()
    keyboard2 = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
    callback_button1 = types.InlineKeyboardButton(text="Open", callback_data="open")
#    callback_button2 = types.InlineKeyboardButton(text="Last Photo", callback_data="photo")
    keyboard.add(callback_button1)
    bot.send_message(message.chat.id, "Welcome!", reply_markup=keyboard)
@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    if call.message:
        if call.data == "open":
            script1 = subprocess.check_output("sshpass -p a ssh root@10.14.0.63 sh /home/pi/Documents/open.sh 2>/dev/null", shell=True)
            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=script1)
#        if call.data == "photo":

#            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text=script2)
if __name__ == '__main__':
    bot.polling(none_stop=True)
def run(self):
        while True:
            self.updates()
            time.sleep(1)
if __name__ == '__main__':
    bot.polling(none_stop=True)

 config.py

# -*- coding: utf-8 -*-
token = 'TOKEN'

Discussions