Created
October 25, 2019 16:09
-
-
Save ettoreleandrotognoli/1ca9b28cb72187504cd7d930db6a7a13 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/python | |
import os | |
import time | |
from asterisk.ami import AMIClient | |
from asterisk.ami import EventListener | |
def event_notification(source, event): | |
os.system('notify-send "%s" "%s"' % (event.name, str(event))) | |
client = AMIClient(address="127.0.0.1",port=5038) | |
future = client.login(username="admin",secret="password") | |
if future.response.is_error(): | |
raise Exception(str(future.response)) | |
client.add_event_listener(EventListener(on_event=event_notification, white_list='Newstate', ChannelStateDesc='Ringing')) | |
try: | |
while True: | |
time.sleep(10) | |
except (KeyboardInterrupt, SystemExit): | |
client.logoff() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment