-
Notifications
You must be signed in to change notification settings - Fork 18
Telegram interface upgrade #328
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
Merged
Merged
Changes from all commits
Commits
Show all changes
163 commits
Select commit
Hold shift + click to select a range
ae091ab
new telegram message proposal
pseusys b1c4da9
only required attachments remain
pseusys 86c15c2
keyboard implemented
pseusys a0a859c
tests reworked
pseusys 89fa2c7
telegram examples debugged
pseusys 3745cff
optional attachment processing added
pseusys 26dc2d6
download all removed, special downloading method created
pseusys 7e65068
callback query added as an attachment
pseusys efece76
callback query conditions added
pseusys c947b4e
remove tg tests; move message tests to core tests
RLKRo 25b8ac9
buttons pulled out of attachments list
pseusys a6c1172
merge
RLKRo b67b497
some errors fixed
pseusys 68b4a37
review issues fixed
pseusys efde7c3
Merge remote-tracking branch 'origin/dev' into feat/telegram_interfac…
pseusys f9a9d79
Merge branch 'dev' into feat/telegram_interface_upgrade
pseusys 6f8de0b
lock file updated
pseusys 771370d
typing fixed
pseusys 1c85052
circular import resolved
pseusys 0cebb97
one more attempt to fix circular import
pseusys a5f0e02
populate attachment method made implemented
pseusys 01947dd
CLI interface separated
pseusys 5e35935
data message equation fixed
pseusys 513f77a
lint applied
pseusys 48bb29f
move callback query to script.conditions
RLKRo e2ea371
condition signature fix
pseusys ea66537
messenger interface parameter added to `get_bytes` method
pseusys db1de9a
async def removed from `extract_message_from_telegram` function
pseusys 19d00f3
docs fixed
pseusys 11cc1a3
condition import added
pseusys 66f82b1
two attachment tutorials fixed
pseusys 2773c9d
attachment tuples changed to sets
pseusys 80fceb5
lint applied
pseusys a5fbe60
docs links fixed
pseusys 8e970c9
Merge branch 'dev' into feat/telegram_interface_upgrade
pseusys 3f815e7
Merge branch 'feat/telegram_interface_upgrade' of https://github.com/…
pseusys f8cecdf
telegram formatted
pseusys 95019ad
lock update
pseusys 8c90763
tuples replaced with sets everywhere
pseusys 30db35a
telegram-specific request attachments added
pseusys 1432893
attachment subclasses moved to extras
pseusys 1bfe524
extras added
pseusys 82e7a3e
lint fixed
pseusys 334cd74
ui replaced with keyboard
pseusys fb2e90a
Merge branch 'feat/telegram_interface_upgrade' of https://github.com/…
pseusys bc406f6
"check_if_" removed
pseusys b08e8f3
undefined message removed
pseusys c79a732
unnecessary type casting removed
pseusys 7853dbc
args and kwargs removed
pseusys 5b9992f
default poll option voter count added
pseusys a3beac9
telegram import check added
pseusys 5dd0751
interface attachments sorted
pseusys b951772
temp attachment dir warning added
pseusys fe99c4c
attachment message clarified
pseusys 595d55d
single attachment sending proposal + sticker
pseusys b31ea18
request and response attachments sorted
pseusys c882abf
Merge branch 'feat/telegram_interface_upgrade' of https://github.com/…
pseusys dd57886
attachments tutorial added
pseusys 33c72cb
advanced tutorial added
pseusys 17280e3
`cached_filename` field added
pseusys 2a1f01a
Tutorial texts altered.
pseusys fb58bda
happy path removed, use cache flag added
pseusys a2e0ca3
literals added + tests started
pseusys a07b73b
Attachment links updated
pseusys 87001c0
new_attachment_tests_added
pseusys aabb3f8
Merge branch 'feat/telegram_interface_upgrade' of https://github.com/…
pseusys b4dd7fc
Merge branch 'dev' into feat/telegram_interface_upgrade
pseusys f478972
Merge branch 'feat/telegram_interface_upgrade' of https://github.com/…
pseusys f1a140a
parametrize fixed for telegram testing
pseusys 3b04c03
Some lint fixed
pseusys 4db3d6f
file path fixed
pseusys 74a0402
attachments type fixed
pseusys 9bc4b3c
supported attachment sets renamed
pseusys cb28fe3
final message test fixed
pseusys d30358b
dot path used instead of slash
pseusys eaad6d2
tutorial tests fixed
pseusys c77f41f
fixed getattribute stack overflow exception
pseusys 28d7f8a
true transition fixed
pseusys 786b3c7
async function marked
pseusys 2277af7
cache dir clear and create reversed
pseusys 6e218b6
pytest warning fixed
pseusys e6d1226
tutorial testing done
pseusys eb07fae
last test step added
pseusys 97be6b9
attachments migrated to wiki
pseusys 33a5c73
pragma removed, inheritance added
pseusys 140f014
some review parts fixed
pseusys 47610a3
venv ignore added back
pseusys 0362fc8
some review comments updated
pseusys 07d887e
erview notes taken into account
pseusys 121b092
additional `Message` serialization test introduced
pseusys 5172f0c
extra field verification added
pseusys 27205bb
github action fixes #1
pseusys 0de3e2b
github action fixes N2
pseusys 83cb8a0
github action fixes N3
pseusys 27678f5
misc typing fixed
pseusys f88e454
Attachment name changed (for windows)
pseusys 85487c3
typing.Annotated fixed
pseusys e634436
Naming fixed once again
pseusys 5ca6e20
telegram import in tests fixed
pseusys 209d975
telegram import fix (again)
pseusys 2f67816
PathStep quotes added
pseusys b61c42d
aiofiles dependency fixed
pseusys cc5772e
typing fixed
pseusys ae35fb9
naming error fixed
pseusys a1df33f
ok, we'll just use any I guess
pseusys d6fbaaf
telegram skip setup correctly
pseusys 4416801
telegram import guarding fixed
pseusys b4d9942
Docs for new DFF classes and functions
pseusys 4cc00b7
tests fixed and updated
pseusys d74a2bc
telegram interfaces renamed
pseusys de12ca2
tutorial documentation introduced
pseusys eeb1bf7
lockfile updated
pseusys 3f0b86e
Merge branch 'dev' into feat/telegram_interface_upgrade
pseusys 21d5af2
locked
pseusys eef4498
dummy type annotation added
pseusys 25ed6b2
field doclink fixed
pseusys 3aa7046
lint fixed partly
pseusys 0c12ad2
formatting fixed
pseusys 652453c
Once again string concatenation fixed
pseusys a50fabe
once again: reformatting
pseusys e55d801
one whitespace removed
pseusys 23ee7f2
json dump fixed
pseusys f82d4ed
import error check added
pseusys c6cd39c
non-native hashes used
pseusys e95d236
hashing description fixed
pseusys d02fa87
log level for tmpdir attachment_dir set to info
RLKRo 680d6b6
add abstract class MessengerInterfaceWithAttachments
RLKRo d8ad2f1
revert init call changes
RLKRo 386f028
return venv ignores
RLKRo 1bd7fff
fix typo
RLKRo 39ca58c
doc improvements
RLKRo 4415606
json-serialization improvements
RLKRo fc98008
patch TG_BOT_TOKEN for tutorial tests
RLKRo 4f49b99
remove pytest.mark.telegram
RLKRo 1765a33
lint
RLKRo 85e84a4
standardize main block in tutorials
RLKRo 2412ba8
merge utils as development utils
RLKRo 1602242
fix test data
RLKRo 7e1d77c
fix MessengerInterfaceWithAttachments usage in tests
RLKRo dfbccf7
cached filename check added
pseusys 037a5d3
telegram API connections updated
pseusys 4313477
media group attachment introduced
pseusys 7b894c7
pickle validator parameter removed
pseusys 64fbef0
Type definition sorted
pseusys 2042186
mediagroup tests added
pseusys d6dfccd
lint fixed
pseusys b1131ef
message send order updated
pseusys 2adb069
make attachment class abstract
RLKRo f20b99c
media group improvements
RLKRo 06f0dcd
rename tutorial tests
RLKRo 98dbd37
add filename to attachments in tutorial
RLKRo 5cad29a
simplify second tutorial with const attachment list
RLKRo 91094a5
minor tutorial changes
RLKRo 2b02c80
improve json-pickle serialization utils
RLKRo 3da516b
allow arbitrary DataAttachments in MediaGroup
RLKRo ed58bdc
add tool for generating test_happy_paths.json
RLKRo eb106c1
minor doc improvements
RLKRo 46c742d
replace populate_attachment with get_attachment_bytes
RLKRo b32492d
test DataAttachment.source type conversions
RLKRo 9adeccd
remove title field
RLKRo e3d154e
replace cached_filename type annotation to Path
RLKRo d33e3f3
remove unused features
RLKRo 365a301
patch attachment comparison to support different OSes
RLKRo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,9 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| from .interface import MessengerInterface, PollingMessengerInterface, CallbackMessengerInterface, CLIMessengerInterface | ||
| from .interface import ( | ||
| MessengerInterface, | ||
| MessengerInterfaceWithAttachments, | ||
| PollingMessengerInterface, | ||
| CallbackMessengerInterface, | ||
| ) | ||
| from .types import PollingInterfaceLoopFunction |
This file contains hidden or 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
This file contains hidden or 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,49 @@ | ||
| from typing import Any, Hashable, List, Optional, TextIO, Tuple | ||
| from uuid import uuid4 | ||
| from dff.messengers.common.interface import PollingMessengerInterface | ||
| from dff.pipeline.types import PipelineRunnerFunction | ||
| from dff.script.core.context import Context | ||
| from dff.script.core.message import Message | ||
|
|
||
|
|
||
| class CLIMessengerInterface(PollingMessengerInterface): | ||
| """ | ||
| Command line message interface is the default message interface, communicating with user via `STDIN/STDOUT`. | ||
| This message interface can maintain dialog with one user at a time only. | ||
| """ | ||
|
|
||
| supported_request_attachment_types = set() | ||
| supported_response_attachment_types = set() | ||
|
|
||
| def __init__( | ||
| self, | ||
| intro: Optional[str] = None, | ||
| prompt_request: str = "request: ", | ||
| prompt_response: str = "response: ", | ||
| out_descriptor: Optional[TextIO] = None, | ||
| ): | ||
| super().__init__() | ||
| self._ctx_id: Optional[Hashable] = None | ||
| self._intro: Optional[str] = intro | ||
| self._prompt_request: str = prompt_request | ||
| self._prompt_response: str = prompt_response | ||
| self._descriptor: Optional[TextIO] = out_descriptor | ||
|
|
||
| def _request(self) -> List[Tuple[Message, Any]]: | ||
| return [(Message(input(self._prompt_request)), self._ctx_id)] | ||
|
|
||
| def _respond(self, responses: List[Context]): | ||
| print(f"{self._prompt_response}{responses[0].last_response.text}", file=self._descriptor) | ||
|
|
||
| async def connect(self, pipeline_runner: PipelineRunnerFunction, **kwargs): | ||
| """ | ||
| The CLIProvider generates new dialog id used to user identification on each `connect` call. | ||
|
|
||
| :param pipeline_runner: A function that should process user request and return context; | ||
| usually it's a :py:meth:`~dff.pipeline.pipeline.pipeline.Pipeline._run_pipeline` function. | ||
| :param \\**kwargs: argument, added for compatibility with super class, it shouldn't be used normally. | ||
| """ | ||
| self._ctx_id = uuid4() | ||
| if self._intro is not None: | ||
| print(self._intro) | ||
| await super().connect(pipeline_runner, **kwargs) |
This file contains hidden or 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,14 +1,4 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| try: | ||
| import telebot | ||
| except ImportError: | ||
| raise ImportError("telebot is not installed. Run `pip install dff[telegram]`") | ||
|
|
||
| from .messenger import TelegramMessenger | ||
| from .interface import PollingTelegramInterface, CallbackTelegramInterface | ||
| from .message import TelegramUI, TelegramMessage, RemoveKeyboard, ParseMode | ||
| from .messenger import ( | ||
| UpdateType, | ||
| telegram_condition, | ||
| ) | ||
| from .abstract import telegram_available | ||
| from .interface import LongpollingInterface, WebhookInterface |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.