-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature request: send message in groupchat #7
Comments
While this is technically already possible, I agree that it is a good idea to implement this directly in the library. Since v1.0 you can do the following: # Controller reacts to messages from @deerspangle
controller = BotController(peer="@deerspangle", client=client)
# This internally merges the controller's `filters.user("@deerspangle")`
# with `filters.chat("@TgIntegration")` as an AND relation
async with controller.collect(filters.chat("@TgIntegration")) as response:
await client.send_message("@TgIntegration", "Hello there!")
assert response.messages[0].chat.username == "TgIntegration"
assert response.messages[0].user.username == "deerspangle" But I do see the need for making tests in groups and channels a high-level concept and would love some ideas on what a good user-facing API for that would be.
However,
|
I like being able to set the context with a context manager (It's in the name, right? |
Oh yes, that's an angle I haven't thought about, you're right! |
Only drawback would be that tests could potentially grow really wide with all those contextanagers..? Like you are always at least two levels deep |
That is true, but feels like it's a rare enough case that people can cope with being tabbed in a few times at that point. Or even extract out parts of their test. |
@joshcoales Hmm, another idea that came to mind was to also stuff that into the central in_the_group = InteractionContext(...)
in_private = InteractionContext(...)
async with controller.collect(count=3, context=in_the_group):
... |
@JosXa Ahh, yeah, that could work also. Might make things a bit neater |
Description
It would be very handy to be able to test that the bot responds correctly to a message in a groupchat. Currently this library only tests against the bot in privmsg
What I Did
Tried feeding chat_id parameter to send_message_await(), but it does not like that, as it's overridden to the bot id
The text was updated successfully, but these errors were encountered: