Skip to content

Commit ba4ab4f

Browse files
Merge pull request #58 from OperationCode/staging
Env var cleanup
2 parents f41ca30 + 11414f0 commit ba4ab4f

5 files changed

Lines changed: 135 additions & 14 deletions

File tree

.gitignore

Lines changed: 115 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,118 @@
22
*.env
33
.pytest_cache
44
!/docker/example.env
5-
*/__pycache__
5+
6+
# Byte-compiled / optimized / DLL files
7+
__pycache__/
8+
*.py[cod]
9+
*$py.class
10+
11+
# C extensions
12+
*.so
13+
14+
# Distribution / packaging
15+
.Python
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
.hypothesis/
54+
.pytest_cache/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
65+
# Flask stuff:
66+
instance/
67+
.webassets-cache
68+
69+
# Scrapy stuff:
70+
.scrapy
71+
72+
# Sphinx documentation
73+
docs/_build/
74+
75+
# PyBuilder
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
.python-version
87+
88+
# celery beat schedule file
89+
celerybeat-schedule
90+
91+
# SageMath parsed files
92+
*.sage.py
93+
94+
# Environments
95+
.env
96+
.venv
97+
env/
98+
venv/
99+
ENV/
100+
env.bak/
101+
venv.bak/
102+
103+
# Spyder project settings
104+
.spyderproject
105+
.spyproject
106+
107+
# Rope project settings
108+
.ropeproject
109+
110+
# mkdocs documentation
111+
/site
112+
113+
# mypy
114+
.mypy_cache/
115+
.dmypy.json
116+
dmypy.json
117+
118+
# Pyre type checker
119+
.pyre/

pybot/__main__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
from . import endpoints
1313
from .plugins import AirtablePlugin
14+
from pybot.endpoints.slack.utils import PORT, HOST
15+
from pybot.endpoints.slack.utils import slack_configs
1416

15-
PORT = os.environ.get("SIRBOT_PORT", 5000)
16-
HOST = os.environ.get("SIRBOT_ADDR", "0.0.0.0")
17-
ACCESS_TOKEN = os.environ.get("OAUTH_ACCESS_TOKEN", "access token")
18-
VERIFICATION_TOKEN = os.environ.get("VERIFICATION_TOKEN ", "verification token")
1917
VERSION = "0.1.0"
2018
logger = logging.getLogger(__name__)
2119

pybot/endpoints/airtable/utils.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
from slack.exceptions import SlackAPIError
88
from slack.io.aiohttp import SlackAPI
99
from pybot.plugins.airtable.api import AirtableAPI
10+
from pybot.endpoints.slack.utils import MENTOR_CHANNEL
1011
from .message_templates.messages import claim_mentee_attachment, mentor_request_text
1112

12-
MENTORS_CHANNEL = os.environ.get("MENTORS_CHANNEL") or "G1DRT62UC"
13-
14-
1513
async def _get_requested_mentor(requested_mentor: Optional[str], slack: SlackAPI,
1614
airtable: AirtableAPI) -> Optional[str]:
1715
try:
@@ -49,17 +47,17 @@ def _create_messages(mentors: List[str], request: dict, requested_mentor_message
4947
'text': mentor_request_text(slack_id, service_translation, request.get('skillsets', None),
5048
requested_mentor_message),
5149
'attachments': claim_mentee_attachment(request['record']),
52-
'channel': MENTORS_CHANNEL
50+
'channel': MENTOR_CHANNEL
5351
}
5452

5553
details_message = {
5654
'text': f"Additional details: {request.get('details', 'None Given')}",
57-
'channel': MENTORS_CHANNEL
55+
'channel': MENTOR_CHANNEL
5856
}
5957

6058
matching_mentors_message = {
6159
'text': "Mentors matching all or some of the requested skillsets: " + ' '.join(mentors),
62-
'channel': MENTORS_CHANNEL
60+
'channel': MENTOR_CHANNEL
6361
}
6462

6563
return first_message, details_message, matching_mentors_message

pybot/endpoints/slack/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from slack.actions import Action
77

88
from pybot.endpoints.slack.utils.action_messages import *
9-
from pybot.endpoints.slack.utils import COMMUNITY_CHANNEL
9+
from pybot.endpoints.slack.utils import COMMUNITY_CHANNEL, TICKET_CHANNEL
1010

1111
logger = logging.getLogger(__name__)
1212

@@ -48,7 +48,7 @@ async def open_ticket(action: Action, app: SirBot):
4848
"""
4949
attachments = ticket_attachments(action)
5050
response = {
51-
'channel': MODERATOR_CHANNEL,
51+
'channel': TICKET_CHANNEL,
5252
'attachments': attachments,
5353
'text': 'New Ticket Submission',
5454
}

pybot/endpoints/slack/utils/__init__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44

55
load_dotenv()
66

7+
MENTOR_CHANNEL = os.environ.get("MENTOR_CHANNEL") or "G1DRT62UC"
78
COMMUNITY_CHANNEL = os.environ.get("COMMUNITY_CHANNEL") or "G12343"
8-
MODERATOR_CHANNEL = os.environ.get('REPORT_CHANNEL') or 'G8NDRJJF9'
9+
MODERATOR_CHANNEL = os.environ.get('MODERATOR_CHANNEL') or 'G8NDRJJF9'
10+
TICKET_CHANNEL = os.environ.get('TICKET_CHANNEL') or 'G8NDRJJF9'
911
APP_TOKEN = os.environ.get('APP_TOKEN') or "123"
1012
YELP_TOKEN = os.environ.get('YELP_TOKEN') or 'token'
1113
PYBACK_HOST = os.environ.get('PYBACK_HOST') or 'pyback'
1214
PYBACK_PORT = os.environ.get('PYBACK_PORT') or 8000
1315
PYBACK_TOKEN = os.environ.get('PYBACK_TOKEN') or 'token'
16+
PORT = os.environ.get("SIRBOT_PORT", 5000)
17+
HOST = os.environ.get("SIRBOT_ADDR", "0.0.0.0")
18+
19+
slack_configs = {
20+
'token': os.environ.get('BOT_OATH_TOKEN'),
21+
'verify': os.environ.get('VERIFICATION_TOKEN'),
22+
'bot_id': os.environ.get('SLACK_BOT_ID'),
23+
'bot_user_id': os.environ.get('SLACK_BOT_ID'),
24+
}

0 commit comments

Comments
 (0)