
Security News
Risky Biz Podcast: Making Reachability Analysis Work in Real-World Codebases
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
msteamsnotifiers: Decorators for automatically notifying an MS Teams channel of events
msteamsnotifiers
makes it easy to automatically send notifications to a channel in MS Teams from Python.
With the retirement of Office 365 Connectors, this library has been updated to use Workflows. Follow the instructions in this simple, short video to set up the Workflow for your Teams channel. You can then get the webhook URL from the "When a Teams webhook request is received" step of the workflow (it's the auto-generated HTTP POST URL field, which has a handy 'copy' button next to it).
Install with pip
:
pip install msteamsnotifiers
Create a Notifier instance by passing in the webhook URL for your workflow:
from msteamsnotifiers import Notifier
notifier = Notifier('<your Microsoft webhook URL>')
This is the simplest way of posting very simple messages to a channel in MS Teams.
from msteamsnotifiers import Notifier
notifier = Notifier('<your Microsoft webhook URL>')
notifier.post_simple_teams_message('Hello channel!')
notifier.post_simple_teams_message('[Markdown formatting](https://www.markdownguide.org/) is supported.')
notifier.post_simple_teams_message('This was sent using [msteamsnotifiers](https://pypi.org/project/msteamsnotifiers/)')
@Notifiy.notify_exceptions
is a decorator that will catch any exceptions in the decorated function and send a specially formatted message with details about the exception to a channel.
from msteamsnotifiers import Notifier
notifier = Notifier('<your Microsoft webhook URL>')
@notifier.notify_exceptions()
def fn_with_potential_exception(a, b):
return a + b
# This function call completes successfully, so the channel will not be notified
sum1 = fn_with_potential_exception(1, 2)
# This function call will generate an exception, resulting in the channel being notified
sum2 = fn_with_potential_exception('a', True)
The format of the channel notification can be specified using the template
decorator argument. If no template is specified, the default template is msteamsnotifiers.default_exception_template
, which includes the full traceback:
default_exception_template = """
*{timestamp}*
Exception caught in **{funcname}()**, File **"{filename}"**
**{message}**
<br>
Node: {machine_name} ({ip_address})
<br>
```{where}```
args: {args}
kwargs: {kwargs}
Full traceback:
```{traceback}```
"""
This package variable can be modified similarly to the default_webhook_url
parameter.
The friendly_tracebacks
module is used to format the included traceback to make it easier to read.
@notify_complete
is a decorator that will send a message to a channel upon successful completion of the decorated function.
from msteamsnotifiers import Notifier
notifier = Notifier('<your Microsoft webhook URL>')
import time
@notifier.notify_complete()
def long_running_function(a, b):
print('Thinking... thinking... thinking...')
time.sleep(3600)
print(f"Aha! The answer is {a+b}!")
return a + b
# The channel will be notified upon completion of this function call
sum1 = long_running_function(1, 2)
The format of this message can be specified using the template
decorator argument. If no template is specified, the default template is msteamsnotifiers.default_completion_template
:
default_completion_template = """
*{timestamp}*
Function completed: **{funcname}()** in file **"{filename}"**
Node: {machine_name} ({ip_address})
args: {args}
kwargs: {kwargs}
"""
pymsteams
(an excellent library, RIP)FAQs
msteamsnotifiers: Decorators for automatically notifying an MS Teams channel of events
We found that msteamsnotifiers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.