Skip to content

Commit

Permalink
pre commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak5598 committed Jun 15, 2024
1 parent 65814f4 commit 98467be
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion data/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -1351,4 +1351,4 @@
"OWASP Foundation web repository",
"https://github.com/OWASP/www-project-pentest-best-practices"
]
}
}
2 changes: 1 addition & 1 deletion data/repos.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"https://github.com/OWASP-BLT/BLT"
]
}


11 changes: 7 additions & 4 deletions src/sammich/plugins/project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
import os

from machine.clients.slack import SlackClient
from machine.plugins.base import MachineBasePlugin
Expand All @@ -9,7 +8,9 @@


class ProjectPlugin(MachineBasePlugin):
def __init__(self, client: SlackClient, settings: CaseInsensitiveDict, storage: PluginStorage):
def __init__(
self, client: SlackClient, settings: CaseInsensitiveDict, storage: PluginStorage
):
super().__init__(client, settings, storage)
with open("data/projects.json") as f:
self.project_data = json.load(f)
Expand All @@ -23,11 +24,13 @@ async def project(self, command):

if project:
project_list = "\n".join(project)
message = f"Hello, here the information about '{project_name}':\n{project_list}"
message = (
f"Hello, here the information about '{project_name}':\n{project_list}"
)
else:
message = (
f"Hello, the project '{project_name}' is not recognized. "
"Please try different query."
)

await command.say(message)
await command.say(message)
17 changes: 10 additions & 7 deletions src/sammich/plugins/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

from machine.clients.slack import SlackClient
from machine.plugins.base import MachineBasePlugin
from machine.plugins.decorators import command
from machine.plugins.decorators import action, command
from machine.storage import PluginStorage
from machine.utils.collections import CaseInsensitiveDict


class RepoPlugin(MachineBasePlugin):
def __init__(self, client: SlackClient, settings: CaseInsensitiveDict, storage: PluginStorage):
def __init__(
self, client: SlackClient, settings: CaseInsensitiveDict, storage: PluginStorage
):
super().__init__(client, settings, storage)
with open("data/repos.json") as f:
self.repo_data = json.load(f)

@command("/repo")
async def repo(self, command):
tech_name = command.text.strip().lower()
Expand Down Expand Up @@ -51,15 +54,15 @@ async def repo(self, command):
}

await self.web_client.chat_postMessage(
channel=channel_id, blocks=message_preview["blocks"], text=fallback_message
channel=channel_id,
blocks=message_preview["blocks"],
text=fallback_message,
)

@action(action_id=re.compile(r"plugin_repo_button_.*"), block_id=None)
async def handle_button_click(self, action):
clicked_button_value = action.payload.actions[0].value
repos = self.repo_data.get(clicked_button_value)
repos_list = "\n".join(repos)
message = (
f"Hello, you can implement your '{clicked_button_value}' knowledge here:\n{repos_list}"
)
await action.say(message)
message = f"Hello, you can implement your '{clicked_button_value}' knowledge here:\n{repos_list}"
await action.say(message)

0 comments on commit 98467be

Please sign in to comment.