Get notified on telegram ¶
This example shows how to set-up a telegram bot. First, you need to setup things in telegram.
Create your own bot ¶
- 
           
On Telegram, search
@ BotFatherand send him a/startmessage; - 
           
Type
/newbotand BotFather will guide you through the creation of a new bot; - 
           
Your bot is now ready: annotate your API token !
 - 
           
On Telegram, search your bot (by the username you just created), and send a
/startmessage 
          Set-up a
          
           
            TeleBot
           
          
          
           ¶
          
         
         
          Now that your bot is ready, you need to store your token on your machine and link
it to
          
           
            codebots
           
          
          . Piece of cake… ;)
         
- 
           
Open your Terminal and type (make sure to remove the < > when pasting your token:
 
telebot set-token <paste-your-token-here>
          - 
           
DONE! if everything went smooth, you should be able to send messages over slack. Try it:
 
telebot send "ciao mamma!"
          In action ¶
          This type of bot is most useful inside scripts (for example to send a message at
some function completion). This is an example implementation (but check the
          
           
            decorator
           
          
          section):
         
from codebots.bots import TeleBot
# Create a TeleBot instance from the credentials that you have set-up before
# (if you don't know how, check the documentation page)
bot = TeleBot()
# # or create a bot an access token file ".tokens/telegram.json"
# bot = TeleBot('.tokens/telegram.json')
# Ask the bot to send a test message
bot.send_message('ciao mamma')