1
0
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:
Waffle
2018-04-28 13:50:59 +03:00
parent 183230e927
commit 3ba9799b98
18 changed files with 102 additions and 102 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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'])

View File

@@ -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 = {}

View File

@@ -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):

View File

@@ -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:

View File

@@ -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:

View File

@@ -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)

View File

@@ -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:

View File

@@ -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

View File

@@ -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()