-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample.py
31 lines (24 loc) · 1.06 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
This example connects to the specified AMI hosts and prints a message when an
account is ringing and when a call is transferred.
"""
from cacofonisk import BaseReporter, AmiRunner
class TransferSpammer(BaseReporter):
def on_event(self, event):
pass
def on_b_dial(self, caller, callee):
callee_account_code = callee.code
caller_id = caller.number
print("{callee.code} is being called by {caller.number}".format(callee=callee, caller=caller))
def on_transfer(self, redirector, party1, party2):
print("Account with account code {redirector.account_code} just "
"transferred a call with callerid {party1.cli} to an extension at "
"{party2.exten}".format(
redirector=redirector, party1=party1,
party2=party2))
if __name__ == '__main__':
ami_host1 = {'host': '127.0.0.1', 'username': 'cacofonisk', 'password': 'bard', 'port': 5038}
ami_hosts = (ami_host1,)
reporter = TransferSpammer()
runner = AmiRunner(ami_hosts, reporter)
runner.run()