Add readme & pep8

This commit is contained in:
eternnoir 2015-09-05 18:12:52 +08:00
parent da729069c2
commit 93aa37768a
2 changed files with 12 additions and 4 deletions

View File

@ -181,6 +181,10 @@ tb.polling(none_stop=False, interval=0, block=True)
# getMe # getMe
user = tb.get_me() user = tb.get_me()
# getUpdates
updates = tb.get_updates()
updates = tb.get_updates(1234,100,20) #get_Updates(offset, limit, timeout):
# sendMessage # sendMessage
tb.send_message(chatid, text) tb.send_message(chatid, text)

View File

@ -5,6 +5,7 @@ import threading
import time import time
import logging import logging
logging.basicConfig() logging.basicConfig()
logger = logging.getLogger('Telebot') logger = logging.getLogger('Telebot')
import re import re
@ -17,6 +18,7 @@ Module : telebot
API_URL = r"https://api.telegram.org/" API_URL = r"https://api.telegram.org/"
class TeleBot: class TeleBot:
""" This is TeleBot Class """ This is TeleBot Class
Methods: Methods:
@ -59,7 +61,7 @@ class TeleBot:
if self.__create_threads: if self.__create_threads:
self.worker_pool = util.ThreadPool(num_threads) self.worker_pool = util.ThreadPool(num_threads)
def get_Updates(self, offset=None,limit=None, timeout=20): def get_updates(self, offset=None, limit=None, timeout=20):
""" """
Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned. Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned.
:param offset: Integer. Identifier of the first update to be returned. :param offset: Integer. Identifier of the first update to be returned.
@ -207,7 +209,8 @@ class TeleBot:
return types.Message.de_json( return types.Message.de_json(
apihelper.send_photo(self.token, chat_id, photo, caption, reply_to_message_id, reply_markup)) apihelper.send_photo(self.token, chat_id, photo, caption, reply_to_message_id, reply_markup))
def send_audio(self, chat_id, audio, duration=None, performer=None, title=None, reply_to_message_id=None, reply_markup=None): def send_audio(self, chat_id, audio, duration=None, performer=None, title=None, reply_to_message_id=None,
reply_markup=None):
""" """
Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format. Use this method to send audio files, if you want Telegram clients to display them in the music player. Your audio must be in the .mp3 format.
:param chat_id:Unique identifier for the message recipient :param chat_id:Unique identifier for the message recipient
@ -220,7 +223,8 @@ class TeleBot:
:return: Message :return: Message
""" """
return types.Message.de_json( return types.Message.de_json(
apihelper.send_audio(self.token, chat_id, audio,duration,performer,title, reply_to_message_id, reply_markup)) apihelper.send_audio(self.token, chat_id, audio, duration, performer, title, reply_to_message_id,
reply_markup))
def send_voice(self, chat_id, voice, duration=None, reply_to_message_id=None, reply_markup=None): def send_voice(self, chat_id, voice, duration=None, reply_to_message_id=None, reply_markup=None):
""" """
@ -233,7 +237,7 @@ class TeleBot:
:return: Message :return: Message
""" """
return types.Message.de_json( return types.Message.de_json(
apihelper.send_voice(self.token, chat_id, voice, duration, reply_to_message_id,reply_markup)) apihelper.send_voice(self.token, chat_id, voice, duration, reply_to_message_id, reply_markup))
def send_document(self, chat_id, data, reply_to_message_id=None, reply_markup=None): def send_document(self, chat_id, data, reply_to_message_id=None, reply_markup=None):
""" """