Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ratlib/api/names.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,11 @@ def getPrivLevel(trigger):
return -1

def addNamesFromV2Response(ratdata):
"""
Update our cached rats with new info from the API
:param ratdata: Should usually be `result['included']` of an API call
:raise: KeyError if `ratdata` is faulty
"""
for rat in ratdata:
if rat['type'] != "rats":
continue
Expand Down
16 changes: 13 additions & 3 deletions sopel_modules/rat_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,9 +1648,19 @@ def cmd_reopen(bot, trigger, id):
"""
try:
result = callapi(bot, 'PUT', data={'status': 'open'}, uri='/rescues/' + str(id), triggernick=str(trigger.nick))
refresh_cases(bot, force=True)
updateBoardIndexes(bot)
bot.say('Reopened case. Cases refreshed, care for your case numbers!')
try:
addNamesFromV2Response(result['included'])
except KeyError:
pass

rescue = Rescue.load(convertV2DataToV1(result['data'][0], single=True))
bot.memory['ratbot']['board'].add(rescue)

with rescue.change():
rescue.data.update({"boardIndex": rescue.boardindex})

save_case_later(bot, rescue, forceFull=True)
bot.say('Reopened case {case.client_name}. It is now #{case.boardIndex}.'.format(case=rescue))
except ratlib.api.http.APIError:
# print('[RatBoard] apierror.')
bot.reply('id ' + str(id) + ' does not exist or other API Error.')
Expand Down