Skip to content

Commit ecad7cb

Browse files
opotttranscental
authored andcommitted
feat: fraud and shipcertqueue macros
1 parent 3649ac9 commit ecad7cb

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

nephthys/macros/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
from nephthys.macros.hello_world import HelloWorld
55
from nephthys.macros.identity import Identity
66
from nephthys.macros.resolve import Resolve
7+
from nephthys.macros.fraud import Fraud
8+
from nephthys.macros.shipcertqueue import ShipCertQueue
79
from nephthys.utils.env import env
810
from nephthys.utils.logging import send_heartbeat
911
from prisma.models import Ticket
1012
from prisma.models import User
1113

1214

13-
macros = [Resolve, HelloWorld, FAQ, Identity]
15+
macros = [Resolve, HelloWorld, FAQ, Identity, Fraud, ShipCertQueue]
1416

1517

1618
async def run_macro(

nephthys/macros/fraud.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from nephthys.actions.resolve import resolve
2+
from nephthys.macros.types import Macro
3+
from nephthys.utils.env import env
4+
5+
6+
class Fraud(Macro):
7+
name = "fraud"
8+
9+
async def run(self, ticket, helper, **kwargs):
10+
"""
11+
A simple macro telling people to use Fraudpheus
12+
"""
13+
sender = await env.db.user.find_first(where={"id": ticket.openedById})
14+
if not sender:
15+
return
16+
user_info = await env.slack_client.users_info(user=sender.slackId)
17+
name = (
18+
user_info["user"]["profile"].get("display_name")
19+
or user_info["user"]["profile"].get("real_name")
20+
or user_info["user"]["name"]
21+
)
22+
await env.slack_client.chat_postMessage(
23+
text=f"Hiya {name}! Would you mind directing any fraud related queries to <@U091HC53CE8>? :rac_cute:\n\nIt'll keep your case confidential and make it easier for the fraud team to keep track of!",
24+
channel=env.slack_help_channel,
25+
thread_ts=ticket.msgTs,
26+
)
27+
await resolve(
28+
ts=ticket.msgTs,
29+
resolver=helper.slackId,
30+
client=env.slack_client,
31+
)

nephthys/macros/shipcertqueue.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from nephthys.actions.resolve import resolve
2+
from nephthys.macros.types import Macro
3+
from nephthys.utils.env import env
4+
5+
6+
class ShipCertQueue(Macro):
7+
name = "shipcertqueue"
8+
9+
async def run(self, ticket, helper, **kwargs):
10+
"""
11+
A simple macro telling people about the ship certification backlog
12+
"""
13+
sender = await env.db.user.find_first(where={"id": ticket.openedById})
14+
if not sender:
15+
return
16+
user_info = await env.slack_client.users_info(user=sender.slackId)
17+
name = (
18+
user_info["user"]["profile"].get("display_name")
19+
or user_info["user"]["profile"].get("real_name")
20+
or user_info["user"]["name"]
21+
)
22+
await env.slack_client.chat_postMessage(
23+
text=f"Hi {name}! Unfortunately, there is a backlog of projects awaiting ship certification; please be patient. \n\n *pssst... voting more will move your project further towards the front of the queue.*",
24+
channel=env.slack_help_channel,
25+
thread_ts=ticket.msgTs,
26+
)
27+
await resolve(
28+
ts=ticket.msgTs,
29+
resolver=helper.slackId,
30+
client=env.slack_client,
31+
)

0 commit comments

Comments
 (0)