Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ignoring other paramaters when attaching files #42

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions tgram/tgbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ async def _send_request(self, method: str, **kwargs) -> Any:
logger.info("Sending request using the method: %s", method)
session = await self._get_session()
data = aiohttp.FormData(quote_fields=False)
has_files, file = False, None
has_files = False

for key, value in kwargs.items():
file = None
if value is None or key == "timeout" or key == "retry":
continue
if isinstance(value, Path):
Expand All @@ -218,8 +219,8 @@ async def _send_request(self, method: str, **kwargs) -> Any:
value = str(value)
data.add_field(
key,
file if has_files else value,
filename=get_file_name(value) if has_files else None,
file or value,
filename=get_file_name(value) if file else None,
)

response = await session.request(
Expand Down
Loading