|
@@ -76,7 +76,7 @@ class GroupMeBot(rollbot.Rollbot[GroupMeMessage]):
|
|
|
return (await upload.json())["payload"]["url"]
|
|
|
|
|
|
async def post_message(self, bot_id: str, text: str, attachments: list[dict[str, str]]):
|
|
|
- await self.context.request.post(
|
|
|
+ result = await self.context.request.post(
|
|
|
"https://api.groupme.com/v3/bots/post",
|
|
|
json={
|
|
|
"bot_id": bot_id,
|
|
@@ -85,10 +85,11 @@ class GroupMeBot(rollbot.Rollbot[GroupMeMessage]):
|
|
|
},
|
|
|
timeout=10,
|
|
|
)
|
|
|
+ self.context.logger.info(f"{result.status} - {await result.json()}")
|
|
|
|
|
|
async def respond(self, res: rollbot.Response):
|
|
|
# sleep for a moment to make groupme not misorder messages
|
|
|
- await asyncio.sleep(0.2)
|
|
|
+ await asyncio.sleep(0.5)
|
|
|
|
|
|
if res.origin_id != "GROUPME":
|
|
|
self.context.logger.error(f"Unable to respond to {res.origin_id}")
|
|
@@ -114,6 +115,16 @@ class GroupMeBot(rollbot.Rollbot[GroupMeMessage]):
|
|
|
)
|
|
|
else:
|
|
|
attachments.append({"type": "image", "url": att.body})
|
|
|
+ if att.name == "reply":
|
|
|
+ if not isinstance(att.body, str):
|
|
|
+ raise ValueError("Invalid reply body type")
|
|
|
+ message += att.body # append reply text to response
|
|
|
+ attachments.append({
|
|
|
+ "type": "reply",
|
|
|
+ "base_reply_id": res.channel_id,
|
|
|
+ "reply_id": res.channel_id,
|
|
|
+ })
|
|
|
+
|
|
|
except:
|
|
|
self.context.debugging = "".join(traceback.format_exc())
|
|
|
message += "Failed to upload one or more attachments!\n"
|