Skip to content

Commit cf4d3ca

Browse files
Bibo-JoshiPoolitzerbastbnlharshil21
authored
Co-authored-by: Poolitzer <[email protected]> Co-authored-by: Bas ten Berge <[email protected]> Co-authored-by: Harshil <[email protected]>
1 parent 8531a7a commit cf4d3ca

32 files changed

Lines changed: 144 additions & 146 deletions

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ contact_links:
33
- name: Telegram Group
44
url: https://telegram.me/pythontelegrambotgroup
55
about: Questions asked on the group usually get answered faster.
6-
- name: IRC Channel
7-
url: https://webchat.freenode.net/?channels=##python-telegram-bot
8-
about: In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel
6+
- name: GitHub Discussions
7+
url: https://github.com/python-telegram-bot/python-telegram-bot/discussions
8+
about: For getting answers to usage on GitHub, Discussions is even better than this bug tracker :)

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Hey there, you have a question? We are happy to answer. Please make sure no simi
1212
1313
To make it easier for us to help you, please read this article https://git.io/JURJO and try to follow the template below as closely as possible.
1414
15-
Please mind that there is also a users' Telegram group at https://t.me/pythontelegrambotgroup for questions about the library. Questions asked there might be answered quicker than here. In case you are unable to join our group due to Telegram restrictions, you can use our IRC channel at https://webchat.freenode.net/?channels=##python-telegram-bot to participate in the group.
15+
Please mind that there is also a users' Telegram group at https://t.me/pythontelegrambotgroup for questions about the library. Questions asked there might be answered quicker than here. Moreover, GitHub Discussions at https://git.io/JG3rk offer a slightly better format to discuss usage questions.
1616
-->
1717

1818
### Issue I am facing

README.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ We have a vibrant community of developers helping each other in our `Telegram gr
6363
:target: https://telegram.me/pythontelegrambotgroup
6464
:alt: Telegram Group
6565

66-
.. image:: https://img.shields.io/badge/IRC-Channel-blue.svg
67-
:target: https://webchat.freenode.net/?channels=##python-telegram-bot
68-
:alt: IRC Bridge
69-
7066
=================
7167
Table of contents
7268
=================
@@ -97,7 +93,7 @@ Introduction
9793

9894
This library provides a pure Python interface for the
9995
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
100-
It's compatible with Python versions 3.6+. PTB might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
96+
It's compatible with Python versions 3.6.2+. PTB might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
10197

10298
In addition to the pure API implementation, this library features a number of high-level classes to
10399
make the development of bots easy and straightforward. These classes are contained in the
@@ -219,13 +215,11 @@ You can get help in several ways:
219215

220216
1. We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
221217

222-
2. In case you are unable to join our group due to Telegram restrictions, you can use our `IRC channel <https://webchat.freenode.net/?channels=##python-telegram-bot>`_.
223-
224-
3. Report bugs, request new features or ask questions by `creating an issue <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_ or `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
218+
2. Report bugs, request new features or ask questions by `creating an issue <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_ or `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
225219

226-
4. Our `Wiki pages <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ offer a growing amount of resources.
220+
3. Our `Wiki pages <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ offer a growing amount of resources.
227221

228-
5. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
222+
4. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
229223

230224

231225
============

README_RAW.rst

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ We have a vibrant community of developers helping each other in our `Telegram gr
6363
:target: https://telegram.me/pythontelegrambotgroup
6464
:alt: Telegram Group
6565

66-
.. image:: https://img.shields.io/badge/IRC-Channel-blue.svg
67-
:target: https://webchat.freenode.net/?channels=##python-telegram-bot
68-
:alt: IRC Bridge
69-
7066
=================
7167
Table of contents
7268
=================
@@ -95,7 +91,7 @@ Introduction
9591

9692
This library provides a pure Python, lightweight interface for the
9793
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
98-
It's compatible with Python versions 3.6+. PTB-Raw might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
94+
It's compatible with Python versions 3.6.2+. PTB-Raw might also work on `PyPy <http://pypy.org/>`_, though there have been a lot of issues before. Hence, PyPy is not officially supported.
9995

10096
``python-telegram-bot-raw`` is part of the `python-telegram-bot <https://python-telegram-bot.org>`_ ecosystem and provides the pure API functionality extracted from PTB. It therefore does *not* have independent release schedules, changelogs or documentation. Please consult the PTB resources.
10197

@@ -202,13 +198,11 @@ You can get help in several ways:
202198

203199
1. We have a vibrant community of developers helping each other in our `Telegram group <https://telegram.me/pythontelegrambotgroup>`_. Join us!
204200

205-
2. In case you are unable to join our group due to Telegram restrictions, you can use our `IRC channel <https://webchat.freenode.net/?channels=##python-telegram-bot>`_.
206-
207-
3. Report bugs, request new features or ask questions by `creating an issue <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_ or `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
201+
2. Report bugs, request new features or ask questions by `creating an issue <https://github.com/python-telegram-bot/python-telegram-bot/issues/new/choose>`_ or `a discussion <https://github.com/python-telegram-bot/python-telegram-bot/discussions/new>`_.
208202

209-
4. Our `Wiki pages <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ offer a growing amount of resources.
203+
3. Our `Wiki pages <https://github.com/python-telegram-bot/python-telegram-bot/wiki/>`_ offer a growing amount of resources.
210204

211-
5. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
205+
4. You can even ask for help on Stack Overflow using the `python-telegram-bot tag <https://stackoverflow.com/questions/tagged/python-telegram-bot>`_.
212206

213207
============
214208
Contributing

examples/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ In this folder are small examples to show what a bot written with `python-telegr
44

55
All examples are licensed under the [CC0 License](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/LICENSE.txt) and are therefore fully dedicated to the public domain. You can use them as the base for your own bots without worrying about copyrights.
66

7+
Do note that we ignore one pythonic convention. Best practice would dictate, in many handler callbacks function signatures, to replace the argument `context` with an underscore, since `context` is an unused local variable in those callbacks. However, since these are examples and not having a name for that argument confuses beginners, we decided to have it present.
8+
79
### [`echobot.py`](https://github.com/python-telegram-bot/python-telegram-bot/blob/master/examples/echobot.py)
810
This is probably the base for most of the bots made with `python-telegram-bot`. It simply replies to each text message with a message that contains the same text.
911

examples/chatmemberbot.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# pylint: disable=C0116
2+
# pylint: disable=C0116,W0613
33
# This program is dedicated to the public domain under the CC0 license.
44

55
"""
@@ -114,7 +114,7 @@ def show_chats(update: Update, context: CallbackContext) -> None:
114114
update.effective_message.reply_text(text)
115115

116116

117-
def greet_chat_members(update: Update, _: CallbackContext) -> None:
117+
def greet_chat_members(update: Update, context: CallbackContext) -> None:
118118
"""Greets new users in chats and announces when someone leaves"""
119119
result = extract_status_change(update.chat_member)
120120
if result is None:
@@ -152,11 +152,9 @@ def main() -> None:
152152
dispatcher.add_handler(ChatMemberHandler(greet_chat_members, ChatMemberHandler.CHAT_MEMBER))
153153

154154
# Start the Bot
155-
# We pass 'allowed_updates' to *only* handle updates with '(my_)chat_member' or 'message'
156-
# If you want to handle *all* updates, pass Update.ALL_TYPES
157-
updater.start_polling(
158-
allowed_updates=[Update.MESSAGE, Update.CHAT_MEMBER, Update.MY_CHAT_MEMBER]
159-
)
155+
# We pass 'allowed_updates' handle *all* updates including `chat_member` updates
156+
# To reset this, simply pass `allowed_updates=[]`
157+
updater.start_polling(allowed_updates=Update.ALL_TYPES)
160158

161159
# Run the bot until you press Ctrl-C or the process receives SIGINT,
162160
# SIGTERM or SIGABRT. This should be used most of the time, since

examples/conversationbot.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# pylint: disable=C0116
2+
# pylint: disable=C0116,W0613
33
# This program is dedicated to the public domain under the CC0 license.
44

55
"""
@@ -36,7 +36,7 @@
3636
GENDER, PHOTO, LOCATION, BIO = range(4)
3737

3838

39-
def start(update: Update, _: CallbackContext) -> int:
39+
def start(update: Update, context: CallbackContext) -> int:
4040
"""Starts the conversation and asks the user about their gender."""
4141
reply_keyboard = [['Boy', 'Girl', 'Other']]
4242

@@ -50,7 +50,7 @@ def start(update: Update, _: CallbackContext) -> int:
5050
return GENDER
5151

5252

53-
def gender(update: Update, _: CallbackContext) -> int:
53+
def gender(update: Update, context: CallbackContext) -> int:
5454
"""Stores the selected gender and asks for a photo."""
5555
user = update.message.from_user
5656
logger.info("Gender of %s: %s", user.first_name, update.message.text)
@@ -63,7 +63,7 @@ def gender(update: Update, _: CallbackContext) -> int:
6363
return PHOTO
6464

6565

66-
def photo(update: Update, _: CallbackContext) -> int:
66+
def photo(update: Update, context: CallbackContext) -> int:
6767
"""Stores the photo and asks for a location."""
6868
user = update.message.from_user
6969
photo_file = update.message.photo[-1].get_file()
@@ -76,7 +76,7 @@ def photo(update: Update, _: CallbackContext) -> int:
7676
return LOCATION
7777

7878

79-
def skip_photo(update: Update, _: CallbackContext) -> int:
79+
def skip_photo(update: Update, context: CallbackContext) -> int:
8080
"""Skips the photo and asks for a location."""
8181
user = update.message.from_user
8282
logger.info("User %s did not send a photo.", user.first_name)
@@ -87,7 +87,7 @@ def skip_photo(update: Update, _: CallbackContext) -> int:
8787
return LOCATION
8888

8989

90-
def location(update: Update, _: CallbackContext) -> int:
90+
def location(update: Update, context: CallbackContext) -> int:
9191
"""Stores the location and asks for some info about the user."""
9292
user = update.message.from_user
9393
user_location = update.message.location
@@ -101,7 +101,7 @@ def location(update: Update, _: CallbackContext) -> int:
101101
return BIO
102102

103103

104-
def skip_location(update: Update, _: CallbackContext) -> int:
104+
def skip_location(update: Update, context: CallbackContext) -> int:
105105
"""Skips the location and asks for info about the user."""
106106
user = update.message.from_user
107107
logger.info("User %s did not send a location.", user.first_name)
@@ -112,7 +112,7 @@ def skip_location(update: Update, _: CallbackContext) -> int:
112112
return BIO
113113

114114

115-
def bio(update: Update, _: CallbackContext) -> int:
115+
def bio(update: Update, context: CallbackContext) -> int:
116116
"""Stores the info about the user and ends the conversation."""
117117
user = update.message.from_user
118118
logger.info("Bio of %s: %s", user.first_name, update.message.text)
@@ -121,7 +121,7 @@ def bio(update: Update, _: CallbackContext) -> int:
121121
return ConversationHandler.END
122122

123123

124-
def cancel(update: Update, _: CallbackContext) -> int:
124+
def cancel(update: Update, context: CallbackContext) -> int:
125125
"""Cancels and ends the conversation."""
126126
user = update.message.from_user
127127
logger.info("User %s canceled the conversation.", user.first_name)

examples/conversationbot2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# pylint: disable=C0116
2+
# pylint: disable=C0116,W0613
33
# This program is dedicated to the public domain under the CC0 license.
44

55
"""
@@ -50,7 +50,7 @@ def facts_to_str(user_data: Dict[str, str]) -> str:
5050
return "\n".join(facts).join(['\n', '\n'])
5151

5252

53-
def start(update: Update, _: CallbackContext) -> int:
53+
def start(update: Update, context: CallbackContext) -> int:
5454
"""Start the conversation and ask user for input."""
5555
update.message.reply_text(
5656
"Hi! My name is Doctor Botter. I will hold a more complex conversation with you. "
@@ -70,7 +70,7 @@ def regular_choice(update: Update, context: CallbackContext) -> int:
7070
return TYPING_REPLY
7171

7272

73-
def custom_choice(update: Update, _: CallbackContext) -> int:
73+
def custom_choice(update: Update, context: CallbackContext) -> int:
7474
"""Ask the user for a description of a custom category."""
7575
update.message.reply_text(
7676
'Alright, please send me the category first, for example "Most impressive skill"'

examples/deeplinking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# pylint: disable=C0116
2+
# pylint: disable=C0116,W0613
33
# This program is dedicated to the public domain under the CC0 license.
44

55
"""Bot that explains Telegram's "Deep Linking Parameters" functionality.
@@ -78,7 +78,7 @@ def deep_linked_level_2(update: Update, context: CallbackContext) -> None:
7878
update.message.reply_text(text, parse_mode=ParseMode.MARKDOWN, disable_web_page_preview=True)
7979

8080

81-
def deep_linked_level_3(update: Update, _: CallbackContext) -> None:
81+
def deep_linked_level_3(update: Update, context: CallbackContext) -> None:
8282
"""Reached through the USING_ENTITIES payload"""
8383
update.message.reply_text(
8484
"It is also possible to make deep-linking using InlineKeyboardButtons.",

examples/echobot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env python
2-
# pylint: disable=C0116
2+
# pylint: disable=C0116,W0613
33
# This program is dedicated to the public domain under the CC0 license.
44

55
"""
@@ -30,7 +30,7 @@
3030

3131
# Define a few command handlers. These usually take the two arguments update and
3232
# context.
33-
def start(update: Update, _: CallbackContext) -> None:
33+
def start(update: Update, context: CallbackContext) -> None:
3434
"""Send a message when the command /start is issued."""
3535
user = update.effective_user
3636
update.message.reply_markdown_v2(
@@ -39,12 +39,12 @@ def start(update: Update, _: CallbackContext) -> None:
3939
)
4040

4141

42-
def help_command(update: Update, _: CallbackContext) -> None:
42+
def help_command(update: Update, context: CallbackContext) -> None:
4343
"""Send a message when the command /help is issued."""
4444
update.message.reply_text('Help!')
4545

4646

47-
def echo(update: Update, _: CallbackContext) -> None:
47+
def echo(update: Update, context: CallbackContext) -> None:
4848
"""Echo the user message."""
4949
update.message.reply_text(update.message.text)
5050

0 commit comments

Comments
 (0)