mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Renaming back pytelegrambotapi module to telebot
This commit is contained in:
parent
183230e927
commit
3ba9799b98
@ -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.
|
||||
|
@ -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 = '<token_string>'
|
||||
@ -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
|
||||
|
||||
|
||||
|
@ -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 = '<api_token>'
|
||||
|
||||
bot = pytelegrambotapi.TeleBot(API_TOKEN)
|
||||
bot = telebot.TeleBot(API_TOKEN)
|
||||
|
||||
# Handle '/start' and '/help'
|
||||
@bot.message_handler(commands=['help', 'start'])
|
||||
|
@ -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 = '<api_token>'
|
||||
|
||||
bot = pytelegrambotapi.TeleBot(API_TOKEN)
|
||||
bot = telebot.TeleBot(API_TOKEN)
|
||||
|
||||
user_dict = {}
|
||||
|
||||
|
@ -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):
|
||||
|
@ -9,7 +9,7 @@ import ssl
|
||||
|
||||
from aiohttp import web
|
||||
|
||||
import pytelegrambotapi
|
||||
import telebot
|
||||
|
||||
|
||||
API_TOKEN = '<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:
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -1,10 +1,10 @@
|
||||
import os
|
||||
|
||||
import pytelegrambotapi
|
||||
import telebot
|
||||
from flask import Flask, request
|
||||
|
||||
TOKEN = '<api_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
|
||||
|
||||
|
||||
|
@ -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()
|
||||
|
2
setup.py
2
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'],
|
||||
|
@ -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
|
@ -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}"
|
@ -7,7 +7,7 @@ except ImportError:
|
||||
|
||||
import six
|
||||
|
||||
from pytelegrambotapi import util
|
||||
from telebot import util
|
||||
|
||||
|
||||
class JsonSerializable:
|
@ -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='<b>bold</b>', 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='<b>bold</b>', 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'
|
||||
|
@ -2,7 +2,7 @@
|
||||
import sys
|
||||
|
||||
sys.path.append('../')
|
||||
from pytelegrambotapi import types
|
||||
from telebot import types
|
||||
|
||||
|
||||
def test_json_user():
|
||||
|
Loading…
x
Reference in New Issue
Block a user