Skip to content

Commit e29a5c5

Browse files
Ali-ToosiarmanexplorerABOLFAZLVALIKHANI
authored
Add publish workflow (#17)
* Rename web page preview param on editMessageText method * Add placeholder parameter to ForceReply type (#12) * Add get_photo on Message type (#16) * Prevent get_chat_state on TelegramUser from returning a tuple (#13) Previously, it would return a tuple where the first item was the state object, the second one was whether or not the state existed before. Now it doesn't return the second item and only returns the state. * Add publish workflow Co-authored-by: Arman MZD <44166374+armanexplorer@users.noreply.github.com> Co-authored-by: ABOLFAZLVALIKHANI <67257233+ABOLFAZLVALIKHANI@users.noreply.github.com>
1 parent 6712ad2 commit e29a5c5

File tree

10 files changed

+39
-10
lines changed

10 files changed

+39
-10
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Publish to PyPI.org
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
pypi:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
- run: python3 -m pip install --upgrade build && python3 -m build
14+
- name: Publish package
15+
uses: pypa/gh-action-pypi-publish@release/v1
16+
with:
17+
password: ${{ secrets.PYPI_API_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ __pycache__/
1111
.AppleDouble
1212
.LSOverride
1313
site/
14-
release
14+
release*
1515
.vscode
1616
db.sqlite3
1717

django_tgbot/bot_api_user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def answerCallbackQuery(self, callback_query_id, text=None, show_alert=None, url
402402
return self.request_and_result(create_params_from_args(locals()), bool)
403403

404404
def editMessageText(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None,
405-
disable_webpage_preview=None,
405+
disable_web_page_preview=None,
406406
reply_markup: Union[
407407
None, InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply] = None) -> Message:
408408

django_tgbot/management/commands/createtgbot.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ def handle(self, *args, **options):
3737
return
3838

3939
with open(os.path.join(dst, 'credentials.py'), 'w') as f:
40-
f.write("# Do not remove these 2 lines:\nBOT_TOKEN = '{}'\nAPP_NAME = '{}'\n".format(bot_token, bot_username))
40+
creds_help_text_lines = [
41+
"# Do not remove these 2 lines:",
42+
f"BOT_TOKEN = '{bot_token}' # You should consider using env variables or a secret manager for this.",
43+
f"APP_NAME = '{bot_username}'"
44+
]
45+
f.write('\n'.join(creds_help_text_lines))
4146

4247
with open(os.path.join(dst, '__init__.py'), 'w') as f:
4348
f.write(

django_tgbot/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ class AbstractTelegramUser(models.Model):
4444
username = models.CharField(max_length=128, null=True, blank=True)
4545

4646
def get_chat_state(self, chat: AbstractTelegramChat):
47-
state = AbstractTelegramState.objects.get_or_create(
47+
state, _ = AbstractTelegramState.objects.get_or_create(
4848
telegram_user__telegram_id=self.telegram_id,
4949
telegram_chat__telegram_id=chat.telegram_id
5050
)
5151
return state
5252

5353
def get_private_chat_state(self):
54-
state = AbstractTelegramState.objects.get_or_create(
54+
state, _ = AbstractTelegramState.objects.get_or_create(
5555
telegram_user__telegram_id=self.telegram_id,
5656
telegram_chat__telegram_id=self.telegram_id
5757
)

django_tgbot/types/forcereply.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
class ForceReply(BasicType):
77
fields = {
88
'force_reply': BasicType.bool_interpreter,
9+
'input_field_placeholder': str,
910
'selective': BasicType.bool_interpreter
1011
}
1112

1213
def __init__(self, obj=None):
1314
super(ForceReply, self).__init__(obj)
1415

1516
@classmethod
16-
def a(cls, force_reply: bool, selective: Optional[bool] = None):
17+
def a(cls, force_reply: bool, input_field_placeholder: Optional[str] = None, selective: Optional[bool] = None):
1718
return super().a(**locals())

django_tgbot/types/message.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ def get_caption(self) -> Optional[str]:
9595

9696
def get_reply_markup(self):
9797
return getattr(self, 'reply_markup', None)
98+
99+
100+
def get_photo(self):
101+
return getattr(self, 'photo', None)
98102

99103

100104
# Placed here to avoid import cycles

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = django-tgbot
3-
version = 1.4.9.2
3+
version = 1.0.0
44
description = A Django app for creating Telegram bots.
55
long_description = file: README.md
66
long_description_content_type = text/markdown

setup.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)