MCPcopy Create free account
hub / github.com/apache/arrow / parse_command

Method parse_command

dev/archery/archery/bot.py:232–249  ·  view source on GitHub ↗
(self, payload)

Source from the content-addressed store, hash-verified

230 self.github = github.Github(**kwargs)
231
232 def parse_command(self, payload):
233 mention = f'@{self.name}'
234 comment = payload['comment']
235
236 if payload['sender']['login'] == self.name:
237 raise EventError("Don't respond to itself")
238 elif payload['action'] not in {'created', 'edited'}:
239 raise EventError("Don't respond to comment deletion")
240 elif not comment['body'].lstrip().startswith(mention):
241 raise EventError("The bot is not mentioned")
242
243 # Parse the comment, removing the bot mentioned (and everything
244 # before it)
245 command = payload['comment']['body'].split(mention)[-1]
246
247 # then split on newlines and keep only the first line
248 # (ignoring all other lines)
249 return command.split("\n")[0].strip()
250
251 def handle(self, event, payload):
252 try:

Callers 1

handleMethod · 0.95

Calls 1

EventErrorClass · 0.85

Tested by

no test coverage detected