Skip to content

Commit

Permalink
tried to shift to slack-machie
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak5598 committed Jun 5, 2024
1 parent ffb9831 commit 3c4986a
Show file tree
Hide file tree
Showing 12 changed files with 1,304 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.ruff_cache
*.code-workspace
.secrets
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ We've created a video tutorial on how to contribute to our repository. You can w
If you need any assistance or have any questions, please reach out to us on Slack.
Thank you for contributing to our BLT Lettuce project!

test
test
1,213 changes: 1,213 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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"
]
}
}
20 changes: 20 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tool.poetry]
name = "lettucetoolkit"
version = "0.1.0"
description = ""
authors = ["Sarthak5598 <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.11"
requests = "^2.32.3"
python-dotenv = "^1.0.1"
gitpython = "^3.1.43"
slack-machine = "^0.37.0"
slackeventsapi = "^3.0.1"
slack-sdk = "^3.27.2"


[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
2 changes: 1 addition & 1 deletion repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
"https://github.com/OWASP-BLT/BLT"
]
}


Empty file added src/__init__.py
Empty file.
Empty file added src/lettuce/__init__.py
Empty file.
Empty file added src/lettuce/plugins/__init__.py
Empty file.
28 changes: 28 additions & 0 deletions src/lettuce/plugins/projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json

import requests
from machine.plugins.base import MachineBasePlugin
from machine.plugins.decorators import command

project_json_path = "/home/DonnieBLT/BLT-Lettuce/projects.json"
with open(project_json_path) as f:
project_data = json.load(f)


class ProjectPlugin(MachineBasePlugin):
@command("/project")
async def project(self, command):
data = requests.form
text = data.get("text")
user_name = data.get("user_name")
project_name = text.strip().lower()

project = project_data.get(project_name)

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

command.say(message)
28 changes: 28 additions & 0 deletions src/lettuce/plugins/repo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import json

import requests
from machine.plugins.base import MachineBasePlugin
from machine.plugins.decorators import command

repo_json_path = "/home/DonnieBLT/BLT-Lettuce/repo.json"
with open(repo_json_path) as f:
repos_data = json.load(f)


class RepoPlugin(MachineBasePlugin):
@command("/project")
async def project(self, command):
data = requests.form
text = data.get("text")
user_name = data.get("user_name")
tech_name = text.strip().lower()

repos = repos_data.get(tech_name)

if repos:
repos_list = "\n".join(repos)
message = f"Hello {user_name}, you can implement your '{tech_name}' knowledge here:\n{repos_list}"
else:
message = f"Hello {user_name}, the technology '{tech_name}' is not recognized. Please try again."

command.say(message)
11 changes: 11 additions & 0 deletions src/local_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from dotenv import dotenv_values

secrets = dotenv_values(".secrets")

SLACK_APP_TOKEN = secrets.get("SLACK_APP_TOKEN")
SLACK_BOT_TOKEN = secrets.get("SLACK_BOT_TOKEN")

PLUGINS = (
"lettuce.plugins.project.ProjectPlugin",
"lettuce.plugins.repo.RepoPlugin",
)

0 comments on commit 3c4986a

Please sign in to comment.