Giter VIP home page Giter VIP logo

fritzbox-missed-calls-telegram-bot's Introduction

Fritzbox Missed Calls Bot

What? This bot will inform you about (fixed-line) calls you missed via the telegram-messenger. It only works if your calls are managed by an AVM FritzBox. If available, it also displays the name associated with the phone number so that you know, who tried to call you - without even beeing at home.

9ce2f028-ad36-11e6-84f4-8e4ae5699d16

Usage

Prerequisites

Software

The versions given here are the ones I used at the time of development. Feel free to experiment with upgrading to other versions but then the code may require tweaking.

First, please install Python 3.7 and then install the necessary packages as superuser/admin (best would probably be a specific Python Environment but that's not a must):

pip install requests==2.24.0, lxml==4.5.1, fritzconnection==1.3.0, python-telegram-bot==12.7

Telegram Bot Token

On Telegram, talk to BotFather to create a bot and get its access-token.

/newbot
# Botfather: name?
internbotname
# Botfather: username?
VisibleNameEndingWithBot
# Botfather: Congrats, your token is TOKEN

You'll need that token later!

FritzBox

  • Find out your FritzBox' IP
    • Good starting point is fritz.box when your in the FritzBox' LAN.
    • If the bot is running the FritzBox' LAN, the local IP is what we need. Usually it's yours but ending on .1.
  • Create a user with access to the call-list and remember its name and password.
    • For security reason, disable access from internet if the bot runs from the LAN.

Don't have a FritzBox at the moment? No problem, open example.py and set mock_fritzbox=True.

Config

Open bot_phonebook.cfg in your favorite UTF-8 compatible text editor. What you see is the configuration in JSON-Format. Search for fritzboxip, fritzboxpassword, fritzboxusername and telegrambot-token and replace with the appropriate.

Run

Now it's time to start our bot. Enter the directory and simply enter:

python example.py or python3 example.py

To stop the bot, you must kill the python process.

From Telegram

In Telegram you can now search for your bots name and start a new chat with him. You can control it via a few commands:

  • /start The bot will inform you about new calls via this chat.
  • /stop The bot will stop informing about new calls via this chat.
  • /info A list of chat ids that are currently subscribed.

So go ahead and type /start and tell a friend to call you. If his phone-number is available via a reverse lookup in the config file, via tellows(Germany) or dastelefonbuch(Germany) his name will show up. Otherwise, it'll just be his number next to a question mark.

Config

bot_phonebook.cfg

  • knownCallId The call-id of the most recent call that the bot has processed. Older calls will be ignored.
  • phonebook A dict with phonenumbers matched to names for reverse lookups. If a callers number cannot be found in this dictionary, a lookup is attempted in several online phonebooks. The result is then stored in here for later lookups.
  • bot
    • clientChatIds IDs of the subscribed Telegram-Chats. These are notified by the bot about new calls.
    • telegramToken The token you got from the BotFather.
    • checkFritzboxInterval The time in seconds between checking the FritzBox for new calls.

Hacking the source

  • Add reverse lookups for phone numbers from your country: Take a look at teh class Phonebook in fritzbox.py. The function that performs the reverse lookup (matching a name to the phone number) is called Phonebook.nameFromNumberLookup and calls one of three functions beginning with nameFrom. Add yours or edit one of them to fit a service providing reverse lookups for your countries phone numbers.

fritzbox-missed-calls-telegram-bot's People

Contributors

nitzel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fritzbox-missed-calls-telegram-bot's Issues

Setup on Raspbian (Raspberry Pi)

hey there sorry for the necrophilia on this git but I wanted to ask if you got any expierience on setting this up on raspian?
I'm pretty new to github and python both so it would be wonderful if you could lend me some help :)

Greetings
Exze

JSON config invalid

Just in case this repo will get any more updates after 4 years, of if anybody wonders.. There is a small issue. In the config there is a comma after "Suppressed phone number" which makes it invalid JSON. Just remove it.

  "phonebook": {
    "None": "Suppressed phone number",
  }

The other issue(s) seem to be that although I updated my bot_phonebook.cfg it was not used for CheckCallList .. I have another IP but it still tries to initialize with the default 192.168.178.1.

For a quick & dirty fix you might adjust line 140 in fritzbox.py.

However, got more issues.. so I've given up for the moment..

"fritzbox-missed-calls-telegram-bot\fritzbotcallinfo\bot.py", line 48, in __init__
    self.updater.job_queue.put(job_minute, next_t=0.0)
AttributeError: 'JobQueue' object has no attribute 'put'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.