I have a Raspberry Pi B+ hooked up to my home network. Sometimes when I'm away from home I need to ssh into it.
I'd like to know if exists a script that can tell me (via sms, telegram or e-mail) its dynamic IP address.
Have you tried using http://www.noip.com/ 's dynamic vpn service? Just install noip2 on your pi, follow the instructions on the website, forward port 22 on your router, and voila you have a domain that allows points to your dynamic ip at home.
You Pi probably has a private ip address it got from your home router. Your router is usually the only device that has a public ip address.
You can ssh into your Pi if you forward port 22 on your router to your Pi's port 22.
You'll still need to know your router's public address though.
One quick way to check your router's current public ip address is to ask duckduckgo.
That address is likely to change in the future, so you'll need something to deal with that.
A Dynamic DNS service lets you access you public ip address by name, even if the address changes.
I started using the free version of no-ip just last week.
(The program (called noip2) is also available for the Pi, but you have to compile it yourself and write the init script too. That's really easy though (no fighting with dependencies or the linker) and it comes with a really good README with an example init script.)
If you don't want to use a dynamic vpn server, you could install
postfix which lets your raspberry pi send email messages.
But you'd probably have to fight...
But once you've got that working, you can get emails on your phone (if you get email on your phone) or get text messages (by having your Pi email the right sms gateway)
You just need to create a cron job that runs a shell script that checks your public ip address and sends you an email if it's changed since the last check.