From 886899a3e31f4015dce4f737393a4b56b3200e96 Mon Sep 17 00:00:00 2001 From: pieter Date: Fri, 3 Jul 2015 01:54:53 +0200 Subject: [PATCH] Merged #21 --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 28b1506..4166581 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ def listener(*messages): """ for m in messages: chatid = m.chat.id - if m.content_type == 'text' + if m.content_type == 'text': text = m.text tb.send_message(chatid, text) @@ -146,7 +146,7 @@ def echo_messages(*messages): """ for m in messages: chatid = m.chat.id - if m.content_type == 'text' + if m.content_type == 'text': text = m.text bot.send_message(chatid, text) ``` @@ -182,24 +182,24 @@ bot = telebot.TeleBot(TOKEN) # Handle /start and /help @bot.message_handler(commands=['start', 'help']) def command_help(message): - bot.send_message(message.chat.id, "Hello, did someone call for help?") + bot.reply_to(message, "Hello, did someone call for help?") # Handles all messages which text matches the regex regexp. # See https://en.wikipedia.org/wiki/Regular_expression # This regex matches all sent url's. @bot.message_handler(regexp='((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)') def command_url(message): - bot.send_message(message.chat.id, "I shouldn't open that url, should I?") + bot.reply_to(message, "I shouldn't open that url, should I?") # Handle all sent documents of type 'text/plain'. @bot.message_handler(func=lambda message: message.document.mime_type == 'text/plain', content_types=['document']) def command_handle_document(message): - bot.send_message(message.chat.id, "Document received, sir!") + bot.reply_to(message, "Document received, sir!") # Default command handler. A lambda expression which always returns True is used for this purpose. @bot.message_handler(func=lambda message: True, content_types=['audio', 'video', 'document', 'text', 'location', 'contact', 'sticker']) def default_command(message): - bot.send_message(message.chat.id, "This is the default command handler.") + bot.reply_to(message, "This is the default command handler.") ``` * And finally, call bot.polling() ```python