Package: cacofonisk
CacofoniskCacofonisk is a framework that connects to the Asterisk PBX, listens to events
on the Asterisk Management Interface (AMI) and tracks the status of calls
currently in progress in Asterisk.Cacofonisk takes a stream of AMI events as input and uses these to keep track
of the channels currently active in Asterisk and how they are related. When
something interesting happens to one of the channels, it will call a method on
a call state Reporter with interesting information about the call, like who is
in the call, and a unique identifier.This data can then be used to send webhooks regarding a call, to notify a
person who is being called, or to log calls being performed.StatusThis product is actively being developed and used at VoIPGRID.UsageRequirementsPython >= 3.4Panoramisk 1.xAsterisk >= 12InstallationCacofonisk is available on Pypi so you can easily install it with pip:$pipinstallcacofoniskTo install the dependencies from source:$python3setup.pyinstallRunningTo run Cacofonisk, you will need two things: a Runner and a Reporter.A Runner is a class which is responsible for passing AMI events to the
Cacofonisk. Two runners are included: an AmiRunner (which connects to the
Asterisk Management Interface) and a FileRunner (which imports AMI events from
a JSON file).A Reporter is a class which takes the interesting data from Cacofonisk and does
awesome things with it. You can find various Reporters in theexamplesfolder.To create your own reporter, you can extend the BaseReporter class and
implement your own event handlers, like so:fromcacofoniskimportAmiRunner,BaseReporterclassReportAllTheThings(BaseReporter):defon_b_dial(self,caller,targets):target_channels=[target.namefortargetintargets]caller_number=caller.caller_id.numprint("{}is now calling{}".format(caller_number,', '.join(target_channels),))defon_up(self,caller,target):target_number=target.caller_id.numcaller_number=caller.caller_id.numprint("{}is now in conversation with{}".format(caller_number,target_number))defon_hangup(self,caller,reason):caller_number=caller.caller_id.numprint("{}is no longer calling (reason:{})".format(caller_number,reason))reporter=ReportAllTheThings()runner=AmiRunner(['tcp://username:password@127.0.0.1:5038'],reporter)runner.run()This reporter can then be passed to a Runner of your choice to process AMI
events.For more information about the parameters of the reporter, please see the docs
in BaseReporter.You can also listen forUserEventsusing theon_user_eventfunction. This can be used to pass additional data
from Asterisk to your Cacofonisk application.Running the testsTo run the test suite:$python3-munittestContributingSee theCONTRIBUTING.mdfile on how to contribute to this project.ContributorsSee theCONTRIBUTORS.mdfile for a list of contributors to the project.RoadmapChangelogThe changelog can be found in theCHANGELOG.mdfile.In progressNo features are currently in progress.FutureNo features are currently scheduled. Have great ideas? Please don't hesitate to share them!Get in touch with a developerIf you want to report an issue see theCONTRIBUTING.mdfile for more info.We will be happy to answer your other questions atopensource@wearespindle.com.LicenseCacofonisk is made available under the MIT license. See theLICENSE filefor more info.