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

feat(bots): Add events for enabling and disabling bots #12551

Conversation

sanskar-soni-9
Copy link
Contributor

@sanskar-soni-9 sanskar-soni-9 commented Jun 20, 2024

☑️ Resolves

Overview

  • The PR introduces BotEnabledEvent and BotDisabledEvent.
  • These events are dispatched when a bot is enabled or disabled through controller or occ.
  • And sends an asynchronous request to the bot server when these events occur.

This allows the bot server to be notified when a bot is enabled or disabled, enabling it to take appropriate action.

Demo Example

2024-06-20.17-30-59.mp4

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not possible
  • 📘 API documentation in docs/ has been updated or is not required
  • 🔖 Capability is added or not needed

@sanskar-soni-9 sanskar-soni-9 marked this pull request as draft June 20, 2024 12:37
@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from d677d44 to 2abc0f9 Compare June 21, 2024 02:15
@sanskar-soni-9 sanskar-soni-9 marked this pull request as ready for review June 21, 2024 02:20
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be documented in https://github.com/nextcloud/spreed/blob/main/docs/bots.md if possible

lib/Service/BotService.php Outdated Show resolved Hide resolved
lib/Service/BotService.php Outdated Show resolved Hide resolved
lib/Service/BotService.php Outdated Show resolved Hide resolved
lib/Events/BotDisabledEvent.php Show resolved Hide resolved
lib/Events/BotEnabledEvent.php Show resolved Hide resolved
@nickvergessen nickvergessen added 2. developing enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: bots 🤖 /commands in chat messages labels Jun 21, 2024
@nickvergessen nickvergessen added this to the 💙 Next Major (30) milestone Jun 21, 2024
@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 2abc0f9 to 61928d5 Compare June 21, 2024 15:23
@sanskar-soni-9
Copy link
Contributor Author

@nickvergessen resolved all the suggestions and also updated the docs please verify, specially the bots.md :)

docs/bots.md Show resolved Hide resolved
docs/bots.md Outdated Show resolved Hide resolved
docs/bots.md Outdated Show resolved Hide resolved
docs/bots.md Outdated Show resolved Hide resolved
@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 61928d5 to 809f366 Compare June 24, 2024 15:08
@nickvergessen
Copy link
Member

Thanks @sanskar-soni-9
Looks good now and I set it to merge after CI ran.

auto-merge was automatically disabled June 25, 2024 09:05

Head branch was pushed to by a user without write access

@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 809f366 to 916e7ef Compare June 25, 2024 09:05
@sanskar-soni-9
Copy link
Contributor Author

fixed linting

@sanskar-soni-9
Copy link
Contributor Author

sanskar-soni-9 commented Jun 25, 2024

@nickvergessen Integration test is failing, with occ talk:bot:setup in case of invalid room token, the value of room with token will be null, so in case of federatedConvesation and RoomNotFound should it directly return from function here instead of ignoring it and adding bot with invalid token?

lib/Command/Bot/Setup.php Show resolved Hide resolved
$output->writeln('<info>Remove bot from given conversations</info>');

foreach ($tokens as $token) {
$event = new BotDisabledEvent($this->roomManager->getRoomByToken($token), $botServer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And similarly we need to check if the room existed here:
grafik

Suggested change
$event = new BotDisabledEvent($this->roomManager->getRoomByToken($token), $botServer);
try {
$room = $this->roomManager->getRoomByToken($token);
} catch (RoomNotFoundException) {
continue;
}
$event = new BotDisabledEvent($room, $botServer);

(+ importing the OCA\Talk\Exceptions\RoomNotFoundException exception)

@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 916e7ef to 9902be1 Compare June 28, 2024 09:38
@sanskar-soni-9
Copy link
Contributor Author

oops dont know how that happened, let me fix this

@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 9902be1 to 4594691 Compare June 28, 2024 09:50
Signed-off-by: Sanskar Soni <sanskarsoni300@gmail.com>
@sanskar-soni-9 sanskar-soni-9 force-pushed the feat/add-events-for-bot-enable-disable branch from 4594691 to e8af04d Compare June 28, 2024 09:53
@sanskar-soni-9
Copy link
Contributor Author

also rebased to the current head

@nickvergessen
Copy link
Member

oops dont know how that happened, let me fix this

It was always broken, just was not a problem so far as the missing room object was not attempted to be used.

@sanskar-soni-9
Copy link
Contributor Author

It was always broken, just was not a problem so far as the missing room object was not attempted to be used.

No no I used both reset HEAD~ and --amend flag so previous commit was also included 😅, I fixed that now

@nickvergessen nickvergessen merged commit 627e68b into nextcloud:main Jun 28, 2024
63 checks passed
Copy link
Contributor

github-actions bot commented Jul 5, 2024

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing enhancement feature: api 🛠️ OCS API for conversations, chats and participants feature: bots 🤖 /commands in chat messages feedback-requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requiring an event whenever a bot is added to or removed from a chatroom
2 participants