Browse Source

Merge lcmbot/token to lcmbot/master

lcmpusher 2 years ago
parent
commit
521a2a21d7
2 changed files with 10 additions and 1 deletions
  1. 9 1
      LCMbot.py
  2. 1 0
      init/lcmbot.service.tuc_example

+ 9 - 1
LCMbot.py

@@ -4,14 +4,22 @@ from telegram.ext import (Updater, CommandHandler, MessageHandler, Filters,
                           CallbackQueryHandler)
 import handlers as hnd
 from tale_handler import TaleHandler
+import os
+import logging
+logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
+                     level=logging.INFO)
 
 import logging
 logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
                      level=logging.INFO)
 
+
+#acquire token from environment variable LCMBOT_TOKEN (string type)
+lcmbot_token = os.environ.get('LCMBOT_TOKEN')
+
 def main():
     # create LCMbot
-    updater = Updater('TOKEN',use_context=True)
+    updater = Updater(lcmbot_token, use_context=True)
     dp = updater.dispatcher
 
     # register handlers

+ 1 - 0
init/lcmbot.service.tuc_example

@@ -9,6 +9,7 @@ User=lcmbot
 Group=lcmbot
 WorkingDirectory=/opt/lcmbot/LCMbot
 Environment=https_proxy=http://192.168.0.1:3128/
+EnvironmentFile=/usr/local/etc/lcmbot/lcmbot.conf
 ExecStart=/home/lcmbot/miniconda2/bin/python2 /opt/lcmbot/LCMbot/LCMbot.py
 Restart=always