Skip to content

Commit

Permalink
add fuzzy search fallback to set_approval_count method
Browse files Browse the repository at this point in the history
  • Loading branch information
markusressel committed Sep 27, 2024
1 parent e267bbc commit 1a8fcf6
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions keel_telegram_bot/bot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,31 @@ async def _set_approval_count_callback(self, update: Update, context: ContextTyp
message = update.effective_message
chat_id = update.effective_chat.id

self._api_client.get_resources()
async def execute(update: Update, context: ContextTypes.DEFAULT_TYPE, item: Resource, data: dict):
bot = context.bot
message = update.effective_message
chat_id = update.effective_chat.id

self._api_client.set_required_approvals_count(
identifier=identifier,
provider=Provider.Kubernetes,
votes_required=count
)
self._api_client.set_required_approvals_count(
identifier=identifier,
provider=Provider.Kubernetes,
votes_required=count
)

resource = self._api_client.get_resource(identifier=identifier)
resource_lines = resource_to_str(resource)
text = resource_lines
resource = self._api_client.get_resource(identifier=identifier)
resource_lines = resource_to_str(resource)
text = resource_lines

await send_message(bot, chat_id, text, reply_to=message.message_id)
await send_message(bot, chat_id, text, reply_to=message.message_id)

items = self._api_client.get_resources()
items = list(filter(lambda x: not self._is_filtered_for(chat_id, x.identifier), items))

# then fuzzy match to "identifier"
await self._response_handler.await_user_selection(
update, context, identifier, choices=items, key=lambda x: x.identifier,
callback=execute,
)

@COMMAND_TIME_APPROVE.time()
@command(name=COMMAND_APPROVE,
Expand Down

0 comments on commit 1a8fcf6

Please sign in to comment.