mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #16 from ntcong/python3
make telebot compatible with python3
This commit is contained in:
commit
d9bd77503f
@ -2,5 +2,6 @@ language: python
|
|||||||
python:
|
python:
|
||||||
- "2.6"
|
- "2.6"
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
- "3.4"
|
||||||
install: "pip install -r requirements.txt"
|
install: "pip install -r requirements.txt"
|
||||||
script: cd tests && py.test
|
script: cd tests && py.test
|
||||||
|
@ -6,7 +6,7 @@ Python Telegram Bot API.
|
|||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
* Need python2
|
* Need python2 or python3
|
||||||
* Install from source
|
* Install from source
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import apihelper
|
from telebot import apihelper, types
|
||||||
import types
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Module : telebot
|
Module : telebot
|
||||||
@ -73,15 +73,15 @@ class TeleBot:
|
|||||||
self.polling_thread.start()
|
self.polling_thread.start()
|
||||||
|
|
||||||
def __polling(self):
|
def __polling(self):
|
||||||
print 'telegram bot start polling'
|
print('telegram bot start polling')
|
||||||
while not self.__stop_polling:
|
while not self.__stop_polling:
|
||||||
try:
|
try:
|
||||||
self.get_update()
|
self.get_update()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print e
|
print(e)
|
||||||
time.sleep(self.interval)
|
time.sleep(self.interval)
|
||||||
|
|
||||||
print 'telegram bot stop polling'
|
print('telegram bot stop polling')
|
||||||
|
|
||||||
def stop_polling(self):
|
def stop_polling(self):
|
||||||
self.__stop_polling = True
|
self.__stop_polling = True
|
||||||
|
@ -133,12 +133,14 @@ def check_result(func_name, result):
|
|||||||
raise ApiError(func_name + r' error.', result)
|
raise ApiError(func_name + r' error.', result)
|
||||||
return result_json
|
return result_json
|
||||||
|
|
||||||
|
|
||||||
def convert_markup(markup):
|
def convert_markup(markup):
|
||||||
if isinstance(markup, types.ReplyKeyboardMarkup):
|
if isinstance(markup, types.ReplyKeyboardMarkup):
|
||||||
return markup.to_json()
|
return markup.to_json()
|
||||||
else:
|
else:
|
||||||
return markup
|
return markup
|
||||||
|
|
||||||
|
|
||||||
class ApiError(Exception):
|
class ApiError(Exception):
|
||||||
def __init__(self, message, result):
|
def __init__(self, message, result):
|
||||||
super(ApiError, self).__init__(message)
|
super(ApiError, self).__init__(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user