From 3ba9799b98d11a16c99e5f10e627b71ddebff65d Mon Sep 17 00:00:00 2001 From: Waffle Date: Sat, 28 Apr 2018 13:50:59 +0300 Subject: [PATCH] Renaming back pytelegrambotapi module to telebot --- examples/deep_linking.py | 4 +- examples/detailed_example/detailed_example.py | 6 +- examples/echo_bot.py | 4 +- examples/step_example.py | 6 +- examples/telebot_bot/telebot_bot.py | 4 +- .../webhook_aiohttp_echo_bot.py | 10 +- .../webhook_cherrypy_echo_bot.py | 10 +- .../webhook_cpython_echo_bot.py | 10 +- .../webhook_flask_echo_bot.py | 10 +- .../webhook_flask_heroku_echo.py | 6 +- .../webhook_tornado_echo_bot.py | 6 +- setup.py | 2 +- {pytelegrambotapi => telebot}/__init__.py | 2 +- {pytelegrambotapi => telebot}/apihelper.py | 8 +- {pytelegrambotapi => telebot}/types.py | 2 +- {pytelegrambotapi => telebot}/util.py | 0 tests/test_telebot.py | 112 +++++++++--------- tests/test_types.py | 2 +- 18 files changed, 102 insertions(+), 102 deletions(-) rename {pytelegrambotapi => telebot}/__init__.py (99%) rename {pytelegrambotapi => telebot}/apihelper.py (99%) rename {pytelegrambotapi => telebot}/types.py (99%) rename {pytelegrambotapi => telebot}/util.py (100%) diff --git a/examples/deep_linking.py b/examples/deep_linking.py index 1d6060e..f92680f 100644 --- a/examples/deep_linking.py +++ b/examples/deep_linking.py @@ -30,10 +30,10 @@ # Steps 1 to 4 will have to be implemented in a web server, using a language such as PHP, Python, C# or Java. These # steps are not shown here. Only steps 5 to 7 are illustrated, some in pseudo-code, with this example. -import pytelegrambotapi +import telebot import time -bot = pytelegrambotapi.TeleBot('TOKEN') +bot = telebot.TeleBot('TOKEN') def extract_unique_code(text): # Extracts the unique_code from the sent /start command. diff --git a/examples/detailed_example/detailed_example.py b/examples/detailed_example/detailed_example.py index 2bafe03..8fad9af 100644 --- a/examples/detailed_example/detailed_example.py +++ b/examples/detailed_example/detailed_example.py @@ -2,8 +2,8 @@ This is a detailed example using almost every command of the API """ -import pytelegrambotapi -from pytelegrambotapi import types +import telebot +from telebot import types import time TOKEN = '' @@ -48,7 +48,7 @@ def listener(messages): print str(m.chat.first_name) + " [" + str(m.chat.id) + "]: " + m.text -bot = pytelegrambotapi.TeleBot(TOKEN) +bot = telebot.TeleBot(TOKEN) bot.set_update_listener(listener) # register listener diff --git a/examples/echo_bot.py b/examples/echo_bot.py index 0cf4cb2..f88d3bf 100644 --- a/examples/echo_bot.py +++ b/examples/echo_bot.py @@ -1,11 +1,11 @@ # This is a simple echo bot using the decorator mechanism. # It echoes any incoming text messages. -import pytelegrambotapi +import telebot API_TOKEN = '' -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) # Handle '/start' and '/help' @bot.message_handler(commands=['help', 'start']) diff --git a/examples/step_example.py b/examples/step_example.py index bf7c0a9..fd8d07d 100644 --- a/examples/step_example.py +++ b/examples/step_example.py @@ -4,12 +4,12 @@ This Example will show you how to use register_next_step handler. """ import time -import pytelegrambotapi -from pytelegrambotapi import types +import telebot +from telebot import types API_TOKEN = '' -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) user_dict = {} diff --git a/examples/telebot_bot/telebot_bot.py b/examples/telebot_bot/telebot_bot.py index d2fbed0..cd29276 100644 --- a/examples/telebot_bot/telebot_bot.py +++ b/examples/telebot_bot/telebot_bot.py @@ -3,7 +3,7 @@ # and goes by the name 'TeleBot (@pyTeleBot)'. Join our group to talk to him! # WARNING: Tested with Python 2.7 -import pytelegrambotapi +import telebot import os text_messages = { @@ -30,7 +30,7 @@ text_messages = { if "TELEBOT_BOT_TOKEN" not in os.environ or "GROUP_CHAT_ID" not in os.environ: raise AssertionError("Please configure TELEBOT_BOT_TOKEN and GROUP_CHAT_ID as environment variables") -bot = pytelegrambotapi.AsyncTeleBot(os.environ["TELEBOT_BOT_TOKEN"]) +bot = telebot.AsyncTeleBot(os.environ["TELEBOT_BOT_TOKEN"]) GROUP_CHAT_ID = int(os.environ["GROUP_CHAT_ID"]) def is_api_group(chat_id): diff --git a/examples/webhook_examples/webhook_aiohttp_echo_bot.py b/examples/webhook_examples/webhook_aiohttp_echo_bot.py index 089366b..d92cff9 100644 --- a/examples/webhook_examples/webhook_aiohttp_echo_bot.py +++ b/examples/webhook_examples/webhook_aiohttp_echo_bot.py @@ -9,7 +9,7 @@ import ssl from aiohttp import web -import pytelegrambotapi +import telebot API_TOKEN = '' @@ -33,10 +33,10 @@ WEBHOOK_URL_BASE = "https://{}:{}".format(WEBHOOK_HOST, WEBHOOK_PORT) WEBHOOK_URL_PATH = "/{}/".format(API_TOKEN) -logger = pytelegrambotapi.logger -pytelegrambotapi.logger.setLevel(logging.INFO) +logger = telebot.logger +telebot.logger.setLevel(logging.INFO) -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) app = web.Application() @@ -45,7 +45,7 @@ app = web.Application() async def handle(request): if request.match_info.get('token') == bot.token: request_body_dict = await request.json() - update = pytelegrambotapi.types.Update.de_json(request_body_dict) + update = telebot.types.Update.de_json(request_body_dict) bot.process_new_updates([update]) return web.Response() else: diff --git a/examples/webhook_examples/webhook_cherrypy_echo_bot.py b/examples/webhook_examples/webhook_cherrypy_echo_bot.py index 8d08142..d0f3da0 100644 --- a/examples/webhook_examples/webhook_cherrypy_echo_bot.py +++ b/examples/webhook_examples/webhook_cherrypy_echo_bot.py @@ -5,7 +5,7 @@ # It echoes any incoming text messages and does not use the polling method. import cherrypy -import pytelegrambotapi +import telebot import logging @@ -30,10 +30,10 @@ WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT) WEBHOOK_URL_PATH = "/%s/" % (API_TOKEN) -logger = pytelegrambotapi.logger -pytelegrambotapi.logger.setLevel(logging.INFO) +logger = telebot.logger +telebot.logger.setLevel(logging.INFO) -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) # WebhookServer, process webhook calls @@ -45,7 +45,7 @@ class WebhookServer(object): cherrypy.request.headers['content-type'] == 'application/json': length = int(cherrypy.request.headers['content-length']) json_string = cherrypy.request.body.read(length).decode("utf-8") - update = pytelegrambotapi.types.Update.de_json(json_string) + update = telebot.types.Update.de_json(json_string) bot.process_new_updates([update]) return '' else: diff --git a/examples/webhook_examples/webhook_cpython_echo_bot.py b/examples/webhook_examples/webhook_cpython_echo_bot.py index 3308fe4..5c1dfc9 100644 --- a/examples/webhook_examples/webhook_cpython_echo_bot.py +++ b/examples/webhook_examples/webhook_cpython_echo_bot.py @@ -6,7 +6,7 @@ import BaseHTTPServer import ssl -import pytelegrambotapi +import telebot import logging @@ -31,10 +31,10 @@ WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT) WEBHOOK_URL_PATH = "/%s/" % (API_TOKEN) -logger = pytelegrambotapi.logger -pytelegrambotapi.logger.setLevel(logging.INFO) +logger = telebot.logger +telebot.logger.setLevel(logging.INFO) -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) # WebhookHandler, process webhook calls @@ -59,7 +59,7 @@ class WebhookHandler(BaseHTTPServer.BaseHTTPRequestHandler): self.send_response(200) self.end_headers() - update = pytelegrambotapi.types.Update.de_json(json_string) + update = telebot.types.Update.de_json(json_string) bot.process_new_messages([update.message]) else: self.send_error(403) diff --git a/examples/webhook_examples/webhook_flask_echo_bot.py b/examples/webhook_examples/webhook_flask_echo_bot.py index e9422a2..92ffa21 100644 --- a/examples/webhook_examples/webhook_flask_echo_bot.py +++ b/examples/webhook_examples/webhook_flask_echo_bot.py @@ -5,7 +5,7 @@ # It echoes any incoming text messages and does not use the polling method. import flask -import pytelegrambotapi +import telebot import logging @@ -30,10 +30,10 @@ WEBHOOK_URL_BASE = "https://%s:%s" % (WEBHOOK_HOST, WEBHOOK_PORT) WEBHOOK_URL_PATH = "/%s/" % (API_TOKEN) -logger = pytelegrambotapi.logger -pytelegrambotapi.logger.setLevel(logging.INFO) +logger = telebot.logger +telebot.logger.setLevel(logging.INFO) -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) app = flask.Flask(__name__) @@ -49,7 +49,7 @@ def index(): def webhook(): if flask.request.headers.get('content-type') == 'application/json': json_string = flask.request.get_data().decode('utf-8') - update = pytelegrambotapi.types.Update.de_json(json_string) + update = telebot.types.Update.de_json(json_string) bot.process_new_updates([update]) return '' else: diff --git a/examples/webhook_examples/webhook_flask_heroku_echo.py b/examples/webhook_examples/webhook_flask_heroku_echo.py index 392d9e9..62d0a90 100644 --- a/examples/webhook_examples/webhook_flask_heroku_echo.py +++ b/examples/webhook_examples/webhook_flask_heroku_echo.py @@ -1,10 +1,10 @@ import os -import pytelegrambotapi +import telebot from flask import Flask, request TOKEN = '' -bot = pytelegrambotapi.TeleBot(TOKEN) +bot = telebot.TeleBot(TOKEN) server = Flask(__name__) @@ -20,7 +20,7 @@ def echo_message(message): @server.route('/' + TOKEN, methods=['POST']) def getMessage(): - bot.process_new_updates([pytelegrambotapi.types.Update.de_json(request.stream.read().decode("utf-8"))]) + bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))]) return "!", 200 diff --git a/examples/webhook_examples/webhook_tornado_echo_bot.py b/examples/webhook_examples/webhook_tornado_echo_bot.py index b6e3a2d..538b7b9 100644 --- a/examples/webhook_examples/webhook_tornado_echo_bot.py +++ b/examples/webhook_examples/webhook_tornado_echo_bot.py @@ -4,7 +4,7 @@ # This example shows webhook echo bot with Tornado web framework # Documenation to Tornado: http://tornadoweb.org -import pytelegrambotapi +import telebot import tornado.web import tornado.ioloop import tornado.httpserver @@ -27,7 +27,7 @@ WEBHOOK_URL_BASE = "https://{0}:{1}/{2}".format(WEBHOOK_HOST, str(WEBHOOK_PORT), # When asked for "Common Name (e.g. server FQDN or YOUR name)" you should reply # with the same value in you put in WEBHOOK_HOST -bot = pytelegrambotapi.TeleBot(API_TOKEN) +bot = telebot.TeleBot(API_TOKEN) class Root(tornado.web.RequestHandler): def get(self): @@ -45,7 +45,7 @@ class webhook_serv(tornado.web.RequestHandler): # length = int(self.request.headers['Content-Length']) json_data = self.request.body.decode("utf-8") - update = pytelegrambotapi.types.Update.de_json(json_data) + update = telebot.types.Update.de_json(json_data) bot.process_new_updates([update]) self.write("") self.finish() diff --git a/setup.py b/setup.py index e95e6d9..1c5529a 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup(name='pyTelegramBotAPI', author='eternnoir', author_email='eternnoir@gmail.com', url='https://github.com/eternnoir/pyTelegramBotAPI', - packages=['pytelegrambotapi'], + packages=['telebot'], license='GPL2', keywords='telegram bot api tools', install_requires=['requests', 'six'], diff --git a/pytelegrambotapi/__init__.py b/telebot/__init__.py similarity index 99% rename from pytelegrambotapi/__init__.py rename to telebot/__init__.py index 3132e2d..8f9b60b 100644 --- a/pytelegrambotapi/__init__.py +++ b/telebot/__init__.py @@ -20,7 +20,7 @@ logger.addHandler(console_output_handler) logger.setLevel(logging.ERROR) -from pytelegrambotapi import apihelper, types, util +from telebot import apihelper, types, util """ Module : telebot diff --git a/pytelegrambotapi/apihelper.py b/telebot/apihelper.py similarity index 99% rename from pytelegrambotapi/apihelper.py rename to telebot/apihelper.py index 53c529e..1173aa3 100644 --- a/pytelegrambotapi/apihelper.py +++ b/telebot/apihelper.py @@ -13,11 +13,11 @@ try: format_header_param = fields.format_header_param except ImportError: format_header_param = None -import pytelegrambotapi -from pytelegrambotapi import types -from pytelegrambotapi import util +import telebot +from telebot import types +from telebot import util -logger = pytelegrambotapi.logger +logger = telebot.logger proxy = None API_URL = "https://api.telegram.org/bot{0}/{1}" diff --git a/pytelegrambotapi/types.py b/telebot/types.py similarity index 99% rename from pytelegrambotapi/types.py rename to telebot/types.py index 84340d4..f996436 100644 --- a/pytelegrambotapi/types.py +++ b/telebot/types.py @@ -7,7 +7,7 @@ except ImportError: import six -from pytelegrambotapi import util +from telebot import util class JsonSerializable: diff --git a/pytelegrambotapi/util.py b/telebot/util.py similarity index 100% rename from pytelegrambotapi/util.py rename to telebot/util.py diff --git a/tests/test_telebot.py b/tests/test_telebot.py index 3a16ac2..6818b5b 100644 --- a/tests/test_telebot.py +++ b/tests/test_telebot.py @@ -7,9 +7,9 @@ import time import pytest import os -import pytelegrambotapi -from pytelegrambotapi import types -from pytelegrambotapi import util +import telebot +from telebot import types +from telebot import util should_skip = 'TOKEN' and 'CHAT_ID' not in os.environ @@ -29,11 +29,11 @@ class TestTeleBot: def listener(messages): assert len(messages) == 100 - tb = pytelegrambotapi.TeleBot('') + tb = telebot.TeleBot('') tb.set_update_listener(listener) def test_message_handler(self): - tb = pytelegrambotapi.TeleBot('') + tb = telebot.TeleBot('') msg = self.create_text_message('/help') @tb.message_handler(commands=['help', 'start']) @@ -45,7 +45,7 @@ class TestTeleBot: assert msg.text == 'got' def test_message_handler_reg(self): - bot = pytelegrambotapi.TeleBot('') + bot = telebot.TeleBot('') msg = self.create_text_message(r'https://web.telegram.org/') @bot.message_handler(regexp='((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)') @@ -57,7 +57,7 @@ class TestTeleBot: assert msg.text == 'got' def test_message_handler_lambda(self): - bot = pytelegrambotapi.TeleBot('') + bot = telebot.TeleBot('') msg = self.create_text_message(r'lambda_text') @bot.message_handler(func=lambda message: r'lambda' in message.text) @@ -69,7 +69,7 @@ class TestTeleBot: assert msg.text == 'got' def test_message_handler_lambda_fail(self): - bot = pytelegrambotapi.TeleBot('') + bot = telebot.TeleBot('') msg = self.create_text_message(r'text') @bot.message_handler(func=lambda message: r'lambda' in message.text) @@ -81,7 +81,7 @@ class TestTeleBot: assert not msg.text == 'got' def test_message_handler_reg_fail(self): - bot = pytelegrambotapi.TeleBot('') + bot = telebot.TeleBot('') msg = self.create_text_message(r'web.telegram.org/') @bot.message_handler(regexp='((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)') @@ -93,7 +93,7 @@ class TestTeleBot: assert not msg.text == 'got' def test_send_message_with_markdown(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markdown = """ *bold text* _italic text_ @@ -103,7 +103,7 @@ class TestTeleBot: assert ret_msg.message_id def test_send_message_with_disable_notification(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markdown = """ *bold text* _italic text_ @@ -114,7 +114,7 @@ class TestTeleBot: def test_send_file(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_document(CHAT_ID, file_data) assert ret_msg.message_id @@ -123,7 +123,7 @@ class TestTeleBot: def test_send_file_dis_noti(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_document(CHAT_ID, file_data, disable_notification=True) assert ret_msg.message_id @@ -132,7 +132,7 @@ class TestTeleBot: def test_send_file_caption(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_document(CHAT_ID, file_data, caption="Test") assert ret_msg.message_id @@ -141,30 +141,30 @@ class TestTeleBot: def test_send_video(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data) assert ret_msg.message_id def test_send_video_dis_noti(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data, disable_notification=True) assert ret_msg.message_id def test_send_video_more_params(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data, 1) assert ret_msg.message_id def test_send_video_more_params_dis_noti(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data, 1, disable_notification=True) assert ret_msg.message_id def test_send_file_exception(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) try: tb.send_document(CHAT_ID, None) assert False @@ -174,7 +174,7 @@ class TestTeleBot: def test_send_photo(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_photo(CHAT_ID, file_data) assert ret_msg.message_id @@ -183,7 +183,7 @@ class TestTeleBot: def test_send_photo_dis_noti(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_photo(CHAT_ID, file_data) assert ret_msg.message_id @@ -192,7 +192,7 @@ class TestTeleBot: def test_send_audio(self): file_data = open('./test_data/record.mp3', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_audio(CHAT_ID, file_data, 1, performer='eternnoir', title='pyTelegram') assert ret_msg.content_type == 'audio' assert ret_msg.audio.performer == 'eternnoir' @@ -200,7 +200,7 @@ class TestTeleBot: def test_send_audio_dis_noti(self): file_data = open('./test_data/record.mp3', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_audio(CHAT_ID, file_data, 1, performer='eternnoir', title='pyTelegram', disable_notification=True) assert ret_msg.content_type == 'audio' @@ -209,19 +209,19 @@ class TestTeleBot: def test_send_voice(self): file_data = open('./test_data/record.ogg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data) assert ret_msg.voice.mime_type == 'audio/ogg' def test_send_voice_dis_noti(self): file_data = open('./test_data/record.ogg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data, disable_notification=True) assert ret_msg.voice.mime_type == 'audio/ogg' def test_get_file(self): file_data = open('./test_data/record.ogg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data) file_id = ret_msg.voice.file_id file_info = tb.get_file(file_id) @@ -229,7 +229,7 @@ class TestTeleBot: def test_get_file_dis_noti(self): file_data = open('./test_data/record.ogg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data, disable_notification=True) file_id = ret_msg.voice.file_id file_info = tb.get_file(file_id) @@ -237,19 +237,19 @@ class TestTeleBot: def test_send_message(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_message(CHAT_ID, text) assert ret_msg.message_id def test_send_message_dis_noti(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_message(CHAT_ID, text, disable_notification=True) assert ret_msg.message_id def test_send_message_with_markup(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markup = types.ReplyKeyboardMarkup() markup.add(types.KeyboardButton("1")) markup.add(types.KeyboardButton("2")) @@ -258,7 +258,7 @@ class TestTeleBot: def test_send_message_with_markup_use_string(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markup = types.ReplyKeyboardMarkup() markup.add("1") markup.add("2") @@ -269,7 +269,7 @@ class TestTeleBot: def test_send_message_with_inlinemarkup(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markup = types.InlineKeyboardMarkup() markup.add(types.InlineKeyboardButton("Google", url="http://www.google.com")) markup.add(types.InlineKeyboardButton("Yahoo", url="http://www.yahoo.com")) @@ -278,28 +278,28 @@ class TestTeleBot: def test_forward_message(self): text = 'CI forward_message Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_message(CHAT_ID, text) ret_msg = tb.forward_message(CHAT_ID, CHAT_ID, msg.message_id) assert ret_msg.forward_from def test_forward_message_dis_noti(self): text = 'CI forward_message Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_message(CHAT_ID, text) ret_msg = tb.forward_message(CHAT_ID, CHAT_ID, msg.message_id, disable_notification=True) assert ret_msg.forward_from def test_reply_to(self): text = 'CI reply_to Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_message(CHAT_ID, text) ret_msg = tb.reply_to(msg, text + ' REPLY') assert ret_msg.reply_to_message.message_id == msg.message_id def test_register_for_reply(self): text = 'CI reply_to Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_message(CHAT_ID, text, reply_markup=types.ForceReply()) reply_msg = tb.reply_to(msg, text + ' REPLY') @@ -311,7 +311,7 @@ class TestTeleBot: tb.process_new_messages([reply_msg]) def test_send_location(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) lat = 26.3875591 lon = -161.2901042 ret_msg = tb.send_location(CHAT_ID, lat, lon) @@ -319,7 +319,7 @@ class TestTeleBot: assert int(ret_msg.location.latitude) == int(lat) def test_send_location_dis_noti(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) lat = 26.3875591 lon = -161.2901042 ret_msg = tb.send_location(CHAT_ID, lat, lon, disable_notification=True) @@ -327,7 +327,7 @@ class TestTeleBot: assert int(ret_msg.location.latitude) == int(lat) def test_send_venue(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) lat = 26.3875591 lon = -161.2901042 ret_msg = tb.send_venue(CHAT_ID, lat, lon, "Test Venue", "1123 Test Venue address") @@ -335,50 +335,50 @@ class TestTeleBot: assert int(lat) == int(ret_msg.venue.location.latitude) def test_send_venue_dis_noti(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) lat = 26.3875591 lon = -161.2901042 ret_msg = tb.send_venue(CHAT_ID, lat, lon, "Test Venue", "1123 Test Venue address", disable_notification=True) assert ret_msg.venue.title == "Test Venue" def test_Chat(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) me = tb.get_me() msg = tb.send_message(CHAT_ID, 'Test') assert me.id == msg.from_user.id assert msg.chat.id == int(CHAT_ID) def test_edit_message_text(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_message(CHAT_ID, 'Test') new_msg = tb.edit_message_text('Edit test', chat_id=CHAT_ID, message_id=msg.message_id) assert new_msg.text == 'Edit test' def test_edit_message_caption(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) msg = tb.send_document(CHAT_ID, file_data, caption="Test") new_msg = tb.edit_message_caption(caption='Edit test', chat_id=CHAT_ID, message_id=msg.message_id) assert new_msg.caption == 'Edit test' def test_get_chat(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ch = tb.get_chat(GROUP_ID) assert str(ch.id) == GROUP_ID def test_get_chat_administrators(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) cas = tb.get_chat_administrators(GROUP_ID) assert len(cas) > 0 def test_get_chat_members_count(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) cn = tb.get_chat_members_count(GROUP_ID) assert cn > 1 def test_edit_markup(self): text = 'CI Test Message' - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) markup = types.InlineKeyboardMarkup() markup.add(types.InlineKeyboardButton("Google", url="http://www.google.com")) markup.add(types.InlineKeyboardButton("Yahoo", url="http://www.yahoo.com")) @@ -407,12 +407,12 @@ class TestTeleBot: def test_send_video_note(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video_note(CHAT_ID, file_data) assert ret_msg.message_id def test_send_media_group(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) img1 = 'https://i.imgur.com/CjXjcnU.png' img2 = 'https://i.imgur.com/CjXjcnU.png' medias = [types.InputMediaPhoto(img1, "View"), types.InputMediaPhoto(img2, "Dog")] @@ -424,7 +424,7 @@ class TestTeleBot: def test_send_media_group_local_files(self): photo = open('../examples/detailed_example/kitten.jpg', 'rb') video = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) medias = [types.InputMediaPhoto(photo, "View"), types.InputMediaVideo(video)] result = tb.send_media_group(CHAT_ID, medias) @@ -434,31 +434,31 @@ class TestTeleBot: def test_send_photo_formating_caption(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_photo(CHAT_ID, file_data, caption='_italic_', parse_mode='Markdown') assert ret_msg.caption_entities[0].type == 'italic' def test_send_video_formatting_caption(self): file_data = open('./test_data/test_video.mp4', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_video(CHAT_ID, file_data, caption='_italic_', parse_mode='Markdown') assert ret_msg.caption_entities[0].type == 'italic' def test_send_audio_formatting_caption(self): file_data = open('./test_data/record.mp3', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_audio(CHAT_ID, file_data, caption='bold', parse_mode='HTML') assert ret_msg.caption_entities[0].type == 'bold' def test_send_voice_formatting_caprion(self): file_data = open('./test_data/record.ogg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_voice(CHAT_ID, file_data, caption='bold', parse_mode='HTML') assert ret_msg.caption_entities[0].type == 'bold' assert ret_msg.voice.mime_type == 'audio/ogg' def test_send_media_group_formatting_caption(self): - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) img1 = 'https://i.imgur.com/CjXjcnU.png' img2 = 'https://i.imgur.com/CjXjcnU.png' medias = [types.InputMediaPhoto(img1, "*View*", parse_mode='Markdown'), @@ -471,6 +471,6 @@ class TestTeleBot: def test_send_document_formating_caption(self): file_data = open('../examples/detailed_example/kitten.jpg', 'rb') - tb = pytelegrambotapi.TeleBot(TOKEN) + tb = telebot.TeleBot(TOKEN) ret_msg = tb.send_document(CHAT_ID, file_data, caption='_italic_', parse_mode='Markdown') assert ret_msg.caption_entities[0].type == 'italic' diff --git a/tests/test_types.py b/tests/test_types.py index 8744943..c174d42 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -2,7 +2,7 @@ import sys sys.path.append('../') -from pytelegrambotapi import types +from telebot import types def test_json_user():