Browse Source

Fix bugs in mkcommand and groupme driver

Kirk Trombley 4 years ago
parent
commit
a2e1fd0dc4
2 changed files with 16 additions and 15 deletions
  1. 14 13
      drivers/groupme.py
  2. 2 2
      mkcommand.sh

+ 14 - 13
drivers/groupme.py

@@ -17,8 +17,8 @@ logging.config.fileConfig("logging.conf", disable_existing_loggers=False)
 with open(os.environ.get("SECRET_FILE", "secrets.toml"), "r") as sfile:
     secrets = toml.load(sfile)
 database_file = os.environ.get("DATABASE_FILE", secrets["database_file"])
-groupme_bots = secrets["groupme_bots"]
-groupme_token = secrets["groupme_token"]
+groupme_bots = secrets["groupme"]["bots"]
+groupme_token = secrets["groupme"]["token"]
 groupme_admins = secrets["admins"]["origin"]
 group_admins = secrets["admins"]["channel"]
 
@@ -97,17 +97,18 @@ class GroupMeBot(rollbot.Rollbot[GroupMeMessage]):
         message = ""
         attachments = []
         try:
-            for att in res.attachments:
-                if att.name == "image":
-                    if isinstance(att.body, bytes):
-                        attachments.append(
-                            {
-                                "type": "image",
-                                "url": await self.upload_image(att.body),
-                            }
-                        )
-                    else:
-                        attachments.append({"type": "image", "url": att.body})
+            if res.attachments is not None:
+                for att in res.attachments:
+                    if att.name == "image":
+                        if isinstance(att.body, bytes):
+                            attachments.append(
+                                {
+                                    "type": "image",
+                                    "url": await self.upload_image(att.body),
+                                }
+                            )
+                        else:
+                            attachments.append({"type": "image", "url": att.body})
         except:
             self.context.debugging = "".join(traceback.format_exc())
             message += "Failed to upload one or more attachments!\n"

+ 2 - 2
mkcommand.sh

@@ -3,7 +3,7 @@
 if [ $# -lt 1 ]
 then
     echo "usage: $0 command-name"
-    echo "  This script generates a file at src/commands/command-name.py, containing the base of a rollbot command."
+    echo "  This script generates a file at commands/commands/command-name.py, containing the base of a rollbot command."
     echo "  The command-name must be a valid python identifier, and should only be composed of lowercase letters and underscores"
     exit 1
 fi
@@ -14,7 +14,7 @@ then
     exit 1
 fi
 
-COMMAND_FILE="./src/commands/$1.py"
+COMMAND_FILE="./commands/commands/$1.py"
 
 if [[ -f $COMMAND_FILE ]]
 then