-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
3,765 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
.. :changelog: | ||
Release History | ||
--------------- | ||
|
||
0.0.1 (2016-04-14) | ||
++++++++++++++++++ | ||
|
||
* Conception | ||
.. :changelog: | ||
Release History | ||
--------------- | ||
|
||
0.1.0 (2016-04-23) | ||
++++++++++++++++++ | ||
|
||
* BareBot class that wraps Telegram Bot APIs methods | ||
* Types classes that wraps Telegram Bot APIs types | ||
|
||
0.0.1 (2016-04-14) | ||
++++++++++++++++++ | ||
|
||
* Conception |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.PHONY: help | ||
help: | ||
@echo "Please use \`make <target>' where <target> is one of" | ||
@echo " bdist to build wheel universal binary distribution" | ||
@echo " clean to clean build artifacts" | ||
@echo " register to register the package to PyPI" | ||
@echo " register-test to register the package to PyPI Test" | ||
@echo " sdist to build source distribution" | ||
@echo " upload to upload ALL the current built distributions to PyPI" | ||
@echo " upload-test to upload ALL the current built distributions to PyPI Test" | ||
|
||
.PHONY: bdist | ||
bdist: | ||
python setup.py bdist_wheel --universal | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -fr build dist .egg pytbo.egg-info | ||
|
||
.PHONY: init | ||
init: | ||
pip install -r requirements.txt | ||
|
||
.PHONY: register | ||
register: | ||
twine register dist/* | ||
|
||
.PHONY: register | ||
register-test: | ||
twine register -r pypitest dist/* | ||
|
||
.PHONY: sdist | ||
sdist: | ||
python setup.py sdist | ||
|
||
.PHONY: upload | ||
upload: | ||
twine upload dist/* | ||
|
||
.PHONY: upload | ||
upload-test: | ||
twine upload -r pypitest dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,85 @@ | ||
Pytbo: Python Telegram Bots made easy | ||
===================================== | ||
|
||
.. image:: https://img.shields.io/pypi/v/pytbo.svg | ||
:target: https://pypi.python.org/pypi/pytbo | ||
|
||
Pytbo is a module aimed at simplifying the creation of `Telegram Bots <https://telegram.org/blog/bot-revolution>`_ using Python. | ||
|
||
A minimum familiarity with Telegram Bots is required to use this library. Please take a look at the `introduction <https://core.telegram.org/bots>`_ and the `FAQ <https://core.telegram.org/bots/faq>`_ before starting. | ||
|
||
Getting Started | ||
--------------- | ||
|
||
To start working with Pytbo, you must have a Bot token. | ||
If you don't know what we're talking about, read how to `create your first bot with BotFather <https://core.telegram.org/bots#6-botfather>`_. | ||
|
||
This is a simple *echo* bot done with Pytbo that looks for updates every 5 seconds. | ||
|
||
.. code-block:: python | ||
import pytbo | ||
import time | ||
# Bot Token received from Telegram | ||
BOT_TOKEN = "MY_BOT_TOKEN" | ||
# Polling interval in seconds | ||
INTERVAL = 5 | ||
# Create bot object | ||
bot = pytbo.BareBot(BOT_TOKEN) | ||
# Print bot information | ||
print("Bot ID......: %s" % (bot.id)) | ||
print("Bot username: %s" % (bot.username)) | ||
# Initialize offset | ||
offset = 0 | ||
# Infinite polling loop | ||
while True: | ||
# Look for updates | ||
updates = bot.getUpdates(offset) | ||
# Handle them | ||
for u in updates: | ||
if u.message: | ||
if u.message.text: | ||
# If the update contains a message | ||
# that contains text, we reply to the | ||
# sender with the same text. | ||
bot.sendMessage( | ||
u.message.chat.id, | ||
u.message.text, | ||
reply_to_message_id=u.message.message_id | ||
) | ||
# Update offset to avoid receiving | ||
# the same update again | ||
offset = u.update_id + 1 | ||
# Sleep | ||
time.sleep(INTERVAL) | ||
Installation | ||
------------ | ||
|
||
To install Pytbo, simply: | ||
|
||
.. code-block:: bash | ||
$ pip install pytbo | ||
Documentation | ||
------------- | ||
|
||
A proper documentation is not yet available, but it will be. | ||
However, useful methods and classes are documented inside the source code. | ||
|
||
Don't be afraid to have a look inside, sometimes is the best way to learn. | ||
|
||
How to Contribute | ||
----------------- | ||
|
||
#. Fork this repository on GitHub to start making your changes to the **master** branch (or branch off of it). | ||
#. Send a pull request. | ||
|
||
Aknowledgements | ||
--------------- | ||
|
||
Thanks to `Kenneth Reitz <https://github.com/kennethreitz>`_ and to all the other developers of the `requests <https://github.com/kennethreitz/requests>`_ module, which is used inside Pytbo and also as a blueprint for this repository and documentation layout. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .bare import * | ||
__title__ = 'pytbo' | ||
__version__ = '0.1.0' | ||
__build__ = 0x000100 | ||
__author__ = 'Alessandro Costa' | ||
__license__ = 'Apache 2.0' | ||
__copyright__ = 'Copyright 2016 Alessandro Costa' | ||
|
||
from .bare import BareBot | ||
from .types import ( Audio, CallbackQuery, Chat, ChosenInlineResult, Contact, Document, File, ForceReply, | ||
InlineKeyboardButton, InlineKeyboardMarkup, InlineQuery, InlineQueryResultArticle, | ||
InlineQueryResultAudio, InlineQueryResultCachedAudio, InlineQueryResultCachedDocument, | ||
InlineQueryResultCachedGif, InlineQueryResultCachedMpeg4Gif, InlineQueryResultCachedPhoto, | ||
InlineQueryResultCachedVideo, InlineQueryResultCachedVoice, InlineQueryResultContact, | ||
InlineQueryResultDocument, InlineQueryResultGif, InlineQueryResultLocation, | ||
InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue, | ||
InlineQueryResultVideo, InlineQueryResultVoice, InputContactMessageContent, | ||
InputLocationMessageContent, InputTextMessageContent, InputVenueMessageContent, | ||
KeyboardButton, Location, Message, MessageEntity, PhotoSize, ReplyKeyboardHide, | ||
ReplyKeyboardMarkup, Sticker, Update, User, UserProfilePhotos, Venue, Video, Voice ) |
Oops, something went wrong.