Skip to content

Commit

Permalink
version 0.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Scarlato (Jungmann) committed Apr 27, 2016
1 parent 085c90f commit dd53eb5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 20 deletions.
6 changes: 5 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
History
-------
0.1.9 (2016-04-27)
++++++++++++++++++

* Update for python-telegram-bot release v4.0.1

0.1.8 (2016-03-22)
++++++++++++++++++

* Update for deprecation in python-telegram-bot release v3.4


0.1.5 (2016-01-28)
++++++++++++++++++

Expand Down
25 changes: 13 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,39 @@ Then use it in a project creating a module ``telegrambot.py`` in your app ::
#myapp/telegrambot.py
from django_telegrambot.apps import DjangoTelegramBot

# Define a few command handlers. These usually take the two arguments bot and
# update. Error handlers also receive the raised TelegramError object in error.
def start(bot, update):
bot.sendMessage(update.message.chat_id, text='Hi!')
def help(bot, update):
bot.sendMessage(update.message.chat_id, text='Help!')
def echo(bot, update):
bot.sendMessage(update.message.chat_id, text=update.message.text)
def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))
def main():
print "Handlers for telegram bot"
logger.info("Loading handlers for telegram bot")
#Utilizzare questa variabile per ottenere il dispatcher relativo al default bot
# Default dispatcher (this is related to the first bot in settings.TELEGRAM_BOT_TOKENS)
dp = DjangoTelegramBot.dispatcher
# in alternativa si può selezionare quale bot usare utilizzando la seguente funzione:
'''
dp = DjangoTelegramBot.getDispatcher('BOT_2_token') #by bot
dp = DjangoTelegramBot.getDispatcher('BOT_2_username') #by bot username

'''
# To get Dispatcher related to a specific bot
# dp = DjangoTelegramBot.getDispatcher('BOT_n_token') #get by bot token
# dp = DjangoTelegramBot.getDispatcher('BOT_n_username') #get by bot username
# on different commands - answer in Telegram
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("help", help)
dp.addHandler(CommandHandler("start", start))
dp.addHandler(CommandHandler("help", help))
# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(echo)
dp.addHandler(MessageHandler([Filters.text], echo))
# log all errors
dp.addErrorHandler(error)
Expand Down
2 changes: 1 addition & 1 deletion django_telegrambot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '0.1.8'
__version__ = '0.1.9'
default_app_config = 'django_telegrambot.apps.DjangoTelegramBot'
13 changes: 8 additions & 5 deletions example/telegrambot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,20 @@
logger = logging.getLogger(__name__)


#in questa parte del file definire il funzionamento del bot aggiungendo gli handler
# Define a few command handlers. These usually take the two arguments bot and
# update. Error handlers also receive the raised TelegramError object in error.
def start(bot, update):
bot.sendMessage(update.message.chat_id, text='Hi!')


def help(bot, update):
bot.sendMessage(update.message.chat_id, text='Help!')


def echo(bot, update):
logger.info('ECHO: %s'%update.message.text)
bot.sendMessage(update.message.chat_id, text=update.message.text)


def error(bot, update, error):
logger.warn('Update "%s" caused error "%s"' % (update, error))

Expand All @@ -31,11 +34,11 @@ def main():
# dp = DjangoTelegramBot.getDispatcher('BOT_n_username') #get by bot username

# on different commands - answer in Telegram
dp.addTelegramCommandHandler("start", start)
dp.addTelegramCommandHandler("help", help)
dp.addHandler(CommandHandler("start", start))
dp.addHandler(CommandHandler("help", help))

# on noncommand i.e message - echo the message on Telegram
dp.addTelegramMessageHandler(echo)
dp.addHandler(MessageHandler([Filters.text], echo))

# log all errors
dp.addErrorHandler(error)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
django>=1.8.0
# Additional requirements go here
python-telegram-bot>=3.4.0
python-telegram-bot>=4.0.1

0 comments on commit dd53eb5

Please sign in to comment.