Getting your drones ip over telegram


I found a cool way to talk to your raspberrypi by creating a telegram bot through their API. or simply go to your telegram account and search for Botfather.
follow the simple instructions and test the example here
after that I modified the example to reply the IP address of the raspberrypi. here is the code below for

#!/usr/bin/env python

import time
import datetime
import telepot
import subprocess
from telepot.loop import MessageLoop
import socket

s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
ip = s.getsockname()[0]

def handle(msg):
chat_id = msg[‘chat’][‘id’]
command = msg[‘text’]
print ‘Got command: %s’ % command

if command == '/ip':
	bot.sendMessage(chat_id, ip)
elif command == '/time':
	bot.sendMessage(chat_id, str(

bot = telepot.Bot(‘put your tocken here’)

MessageLoop(bot, handle).run_as_thread()
print ‘working…’

while 1: