Break out into a module

This commit is contained in:
2022-06-08 18:28:25 +01:00
parent a53d55b2f1
commit 22b7d82708
2 changed files with 6 additions and 3 deletions

5
smsbot.py → smsbot/__init__.py Executable file → Normal file
View File

@@ -1,4 +1,3 @@
#!/usr/bin/env python
import logging
import os
import sys
@@ -147,7 +146,7 @@ class TwilioWebhookHandler(object):
serve(self.app, host=host, port=port)
if __name__ == "__main__":
def main():
logging.basicConfig(level=logging.INFO)
listen_host = os.environ.get('SMSBOT_LISTEN_HOST') or '0.0.0.0'
@@ -165,4 +164,4 @@ if __name__ == "__main__":
# Start webhooks
webhooks = TwilioWebhookHandler()
webhooks.set_bot(telegram_bot)
webhooks.serve()
webhooks.serve(host=listen_host, port=listen_port)

4
smsbot/__main__.py Normal file
View File

@@ -0,0 +1,4 @@
from . import main
if __name__ == '__main__':
main()