Open joshand opened 6 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
ciscosparkbot/Spark.py | 27 | 32 | 84.38% | ||
<!-- | Total: | 27 | 32 | 84.38% | --> |
Totals | |
---|---|
Change from base Build 38: | -0.8% |
Covered Lines: | 160 |
Relevant Lines: | 172 |
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
ciscosparkbot/Spark.py | 27 | 32 | 84.38% | ||
<!-- | Total: | 27 | 32 | 84.38% | --> |
Totals | |
---|---|
Change from base Build 38: | -0.8% |
Covered Lines: | 160 |
Relevant Lines: | 172 |
@kecorbin Any feedback on this PR?
I was in need of a bot that could monitor memberships data, so I extended this one to do that.
With the changes in the PR, the default behavior is still in tact. However, here is an example of how you would monitor memberships data:
In your main code, when you create an instance of the bot, add the "wh_resource" and "wh_event" parameters:
Then, add a new command for the resource you want to monitor:
bot.add_command('memberships', '*', check_memberships)
Finally, add a function to handle that command. For example, I needed the bot (which is assigned to the room as a moderator) to be able to remove anyone from a room who is not in a set of whitelisted domains (i.e., to ensure that a room stays "internal-only"). This function has an additional parameter (sp in my example), which is used to directly access the SparkAPI object.