diff --git a/README.md b/README.md index e69de29..ee111f7 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,3 @@ +# dialin + +If this ever works for inbound calling, it will connect the pipewire input and output of the machine to the call, so you can join an ongoing video call in discord, zoom or whatever. diff --git a/main.py b/main.py new file mode 100644 index 0000000..472d9aa --- /dev/null +++ b/main.py @@ -0,0 +1,43 @@ +from PySIP.sip_account import SipAccount +from PySIP.sip_call import SipCall +import os +import asyncio +from dotenv import load_dotenv +import logging + +# Load SIP credentials from .env file +load_dotenv() +try: + if len(os.environ["SIP_CONN_TYPE"]) < 1: + os.environ["SIP_CONN_TYPE"] = "AUTO" +except: + os.environ["SIP_CONN_TYPE"] = "AUTO" + +account = SipAccount( + os.environ["SIP_USERNAME"], + os.environ["SIP_PASSWORD"], + os.environ["SIP_SERVER"], + connection_type = os.environ["SIP_CONN_TYPE"] +) + + +async def main(): + logger = logging.getLogger(__name__) + logger.setLevel(logging.DEBUG) + await account.register() + + @account.on_incoming_call + async def handle_incoming_call(call: SipCall): + print("incoming call!") + await call.accept() # or call.reject() or call.busy() + await call.call_handler.say("Thank you for calling us!") + await call.call_handler.hangup() + + loop = 0 + while True: + await asyncio.sleep(60) + loop = loop + 1 + logger.log(logging.INFO, f"Hey, we've been running for {loop} minutes...just so you know.") + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..be1e078 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +PySIPio +scipy