Skip to content

Commit cb35f3d

Browse files
authored
Merge branch 'master' into master
2 parents 1c06b99 + a0ea5ba commit cb35f3d

21 files changed

Lines changed: 1088 additions & 535 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ dist/
1919
downloads/
2020
eggs/
2121
.eggs/
22-
lib/
2322
lib64/
2423
parts/
2524
sdist/

Pipfile.lock

Lines changed: 227 additions & 223 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pybot/__main__.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,9 @@
1414
from pybot.endpoints.slack.utils import PORT, HOST
1515
from pybot.endpoints.slack.utils import slack_configs
1616

17-
VERSION = "0.1.0"
17+
VERSION = "0.2.0"
1818
logger = logging.getLogger(__name__)
1919

20-
slack_configs = {
21-
'token': os.environ.get('BOT_OATH_TOKEN'),
22-
'verify': os.environ.get('VERIFICATION_TOKEN'),
23-
'bot_id': os.environ.get('SLACK_BOT_ID'),
24-
'bot_user_id': os.environ.get('SLACK_BOT_ID'),
25-
}
26-
2720

2821
def make_sentry_logger():
2922
client = raven.Client(

pybot/endpoints/airtable/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def mentor_request(request: dict, app: SirBot) -> None:
2525
id_fallback = f" [couldn't find user - email provided: {request['email']} ]"
2626
slack_id = await _slack_user_id_from_email(request['email'], slack, fallback=id_fallback)
2727

28-
futures = [app.plugins['airtable'].api.translate_service_id(request['service']),
28+
futures = [airtable.get_name_from_record_id('Services', request['service']),
2929
_get_requested_mentor(request.get('requested_mentor'), slack, airtable),
3030
_get_matching_skillset_mentors(request.get('skillsets'), slack, airtable)]
3131

pybot/endpoints/airtable/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
from typing import List, Optional, Tuple
32

43
from sirbot import SirBot
@@ -10,12 +9,13 @@
109
from pybot.endpoints.slack.utils import MENTOR_CHANNEL
1110
from .message_templates.messages import claim_mentee_attachment, mentor_request_text
1211

12+
1313
async def _get_requested_mentor(requested_mentor: Optional[str], slack: SlackAPI,
1414
airtable: AirtableAPI) -> Optional[str]:
1515
try:
1616
if not requested_mentor:
1717
return None
18-
mentor = await airtable.get_mentor_from_record_id(requested_mentor)
18+
mentor = await airtable.get_row_from_record_id('Mentors', requested_mentor)
1919
email = mentor['Email']
2020
slack_user_id = await _slack_user_id_from_email(email, slack)
2121
return f" Requested mentor: <@{slack_user_id}>"

pybot/endpoints/slack/actions.py

Lines changed: 0 additions & 222 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from .general_actions import claimed, reset_claim
2+
from .help_ticket import open_ticket, ticket_status
3+
from .report_message import open_report_dialog, send_report
4+
from .mentor_request import mentor_request_submit, cancel_mentor_request, add_skillset, \
5+
clear_skillsets, open_details_dialog, mentor_details_submit, claim_mentee, set_requested_mentor, set_requested_service, \
6+
set_group
7+
from .new_member import member_greeted, open_suggestion, post_suggestion, reset_greet, resource_buttons
8+
9+
10+
def create_endpoints(plugin):
11+
# simple actions that can be used in multiple scenarios
12+
plugin.on_action("claimed", claimed, name='claimed', wait=False)
13+
plugin.on_action("claimed", reset_claim, name='reset_claim', wait=False)
14+
15+
# new member interactive actions
16+
plugin.on_action("resource_buttons", resource_buttons, wait=False)
17+
plugin.on_action("greeted", member_greeted, name='greeted', wait=False)
18+
plugin.on_action("greeted", reset_greet, name='reset_greet', wait=False)
19+
plugin.on_action("suggestion", open_suggestion, wait=False)
20+
plugin.on_action("suggestion_modal", post_suggestion, wait=False)
21+
22+
# reporting related interactive actions
23+
plugin.on_action("report_message", open_report_dialog, wait=False)
24+
plugin.on_action("report_dialog", send_report, wait=False)
25+
26+
# help ticket/request interactive actions
27+
plugin.on_action("open_ticket", open_ticket, wait=False)
28+
plugin.on_action("ticket_status", ticket_status, wait=False)
29+
30+
# mentorship related interactive actions
31+
plugin.on_action("mentor_request_submit", mentor_request_submit, name='submit', wait=False)
32+
plugin.on_action("mentor_request_submit", cancel_mentor_request, name='cancel', wait=False)
33+
34+
# plugin.on_action("mentor_request_update", mentor_request_update, wait=False)
35+
plugin.on_action("mentor_request_update", add_skillset, name='skillset', wait=False)
36+
plugin.on_action("mentor_request_update", clear_skillsets, name='clearSkills', wait=False)
37+
plugin.on_action("mentor_request_update", open_details_dialog, name='addDetails', wait=False)
38+
plugin.on_action("mentor_request_update", set_requested_mentor, name='mentor', wait=False)
39+
plugin.on_action("mentor_request_update", set_requested_service, name='service', wait=False)
40+
plugin.on_action("mentor_request_update", set_group, name='group', wait=False)
41+
42+
plugin.on_action("mentor_details_submit", mentor_details_submit, wait=False)
43+
plugin.on_action("claim_mentee", claim_mentee, wait=False)
44+
plugin.on_action("reset_claim_mentee", claim_mentee, wait=False)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from sirbot import SirBot
2+
from slack import methods
3+
from slack.actions import Action
4+
5+
from pybot.endpoints.slack.utils.action_messages import claimed_attachment, base_response, not_claimed_attachment
6+
7+
8+
async def claimed(action: Action, app: SirBot):
9+
"""
10+
Provides basic "claim" functionality for use-cases that don't have any other effects.
11+
12+
Simply updates the button to allow resets and displays the user and time it was clicked.
13+
"""
14+
response = base_response(action)
15+
user_id = action['user']['id']
16+
17+
attachments = action['original_message']['attachments']
18+
19+
for index, attachment in enumerate(attachments):
20+
if 'callback_id' in attachment and attachment['callback_id'] == 'claimed':
21+
attachments[index] = claimed_attachment(user_id)
22+
response['attachments'] = attachments
23+
24+
await app.plugins['slack'].api.query(methods.CHAT_UPDATE, response)
25+
26+
27+
async def reset_claim(action: Action, app: SirBot):
28+
"""
29+
Provides basic "unclaim" functionality for use-cases that don't have any other effects.
30+
31+
Updates the button back to its initial state
32+
"""
33+
response = base_response(action)
34+
35+
attachments = action['original_message']['attachments']
36+
for index, attachment in enumerate(attachments):
37+
if 'callback_id' in attachment and attachment['callback_id'] == 'claimed':
38+
attachments[index] = not_claimed_attachment()
39+
40+
response['attachments'] = attachments
41+
await app.plugins['slack'].api.query(methods.CHAT_UPDATE, response)

0 commit comments

Comments
 (0)