mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-12-22 14:35:00 +01:00
Merge branch 'master' of https://github.com/leandrotoledo/python-telegram-bot
This commit is contained in:
commit
448cbdbd00
4 changed files with 31 additions and 16 deletions
|
@ -2,9 +2,20 @@
|
|||
|
||||
'''Simple Bot to reply Telegram messages'''
|
||||
|
||||
import logging
|
||||
import telegram
|
||||
import time
|
||||
|
||||
|
||||
LAST_UPDATE_ID = None
|
||||
|
||||
|
||||
def main():
|
||||
global LAST_UPDATE_ID
|
||||
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
# Telegram Bot Authorization Token
|
||||
bot = telegram.Bot('TOKEN')
|
||||
|
||||
|
@ -15,8 +26,12 @@ try:
|
|||
except IndexError:
|
||||
LAST_UPDATE_ID = None
|
||||
|
||||
while True:
|
||||
echo(bot)
|
||||
time.sleep(3)
|
||||
|
||||
def echo():
|
||||
|
||||
def echo(bot):
|
||||
global LAST_UPDATE_ID
|
||||
|
||||
# Request updates from last updated_id
|
||||
|
@ -36,6 +51,4 @@ def echo():
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
while True:
|
||||
echo()
|
||||
time.sleep(3)
|
||||
main()
|
||||
|
|
|
@ -5,14 +5,16 @@
|
|||
|
||||
__author__ = 'leandrotoledodesouza@gmail.com'
|
||||
|
||||
import logging
|
||||
import telegram
|
||||
import urllib
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
bot = telegram.Bot('TOKEN') # Telegram Bot Authorization Token
|
||||
|
||||
global LAST_UPDATE_ID
|
||||
LAST_UPDATE_ID = bot.getUpdates()[-1].update_id # Get lastest update
|
||||
|
||||
while True:
|
||||
|
|
|
@ -18,9 +18,6 @@ import logging
|
|||
from telegram import (User, Message, Update, UserProfilePhotos, TelegramError,
|
||||
ReplyMarkup, InputFile, TelegramObject)
|
||||
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
|
||||
|
||||
class Bot(TelegramObject):
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import logging
|
||||
import unittest
|
||||
from tests.test_bot import BotTest
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
testsuite = unittest.TestLoader().loadTestsFromTestCase(BotTest)
|
||||
unittest.TextTestRunner(verbosity=1).run(testsuite)
|
||||
|
|
Loading…
Reference in a new issue