@responder(pattern="^grab (?P<id>\d+)$", form="grab <issue>", help="Troubleshoot a particular issue")
def grab(conversation, id):
  id = int(id)
  issue = Issue.byID(id)

  if not issue:
    conversation.say("There is no issue with the ID %d" % id)
  elif not issue.hasSOP:
    conversation.say("Unfortunately that issue doesn't have an SOP associated with it. "
                     "All I can do is describe the problem to you and wait for you to "
                     "<b>resolve<b> it manually")
    conversation.say(issue.description)
    contextSummary = '\n'.join("%s: %s" % info for info in issue.context.data.items())
    conversation.say(contextSummary, useHTML=False)
  else:
    existingAgent = issue.context['agent']

    if existingAgent:
      if existingAgent.conversation is conversation:
        conversation.say("You are already troubleshooting this issue!")
        return
      existingAgent.conversation.say("<b>%s has taken over this issue.</b>" % conversation.buddyName)
      existingAgent.currentIssue = None
      existingAgent.conversation.nevermind()

    conversation.say("Ok, I am assigning issue #%d to you." % id)
    agent = SupportAgent(conversation.buddy)
    #Make sure the agent is available first
    agent.ready = True
    agent.currentIssue = None
    agent.conversation.nevermind()

    agent.engage(issue)
dataset/ETHPy150Open OrbitzWorldwide/droned/droned/lib/droned/responders/support.py/grab/original