Skip to content

Commit

Permalink
Merge pull request #33 from kossiitkgp/koss-yy
Browse files Browse the repository at this point in the history
Add feature of koss-yy tag
  • Loading branch information
lurkingryuu authored May 8, 2024
2 parents fd5c9d3 + a1089db commit 8bcbd22
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 29 deletions.
65 changes: 38 additions & 27 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,37 +356,48 @@ def tag():
undefined = []
for group in groups.split(','):
if group in ['ctm', 'ctms', 'fresher', 'freshers']:
positions.append('ctm')
positions.append('23')
elif group in ['exec', 'execs', 'executive', 'executives']:
positions.append('exec')
positions.append('22')
elif group in ['adv', 'advisor', 'advisors']:
# position = 'advisor'
positions.append('advisor')
elif group.lower() in [f'koss-{year}' for year in range(20, 23 + 1)]:
positions.append(group.split('-')[1])
else:
undefined.append(group)

# sending the error message if the group name is not valid
if undefined:
try:
# sending the error message if the group name is not valid
if undefined:
client.chat_postEphemeral(
channel=channel,
user=user,
text=f"Hey <@{user}>!\n"
f"I don't know what you mean by {', '.join(undefined)}\n"
"```Usage:\n"
"/tag <groups, (comma seperated. !! do not give spaces)> <message>\n"
"/tag <groups, (comma seperated. !! do not give spaces)> (In this case, message will be 'Tagged "
"you')\n\n"
"Groups:\n"
"- ctm | ctms | fresher | freshers\n"
"- exec | execs | executive | executives\n"
"- adv | advisor | advisors\n\n"
"- koss-20 | koss-21 | koss-22 | koss-23```\n"
"Message:\n"
"The message can be anything you want to send to the tagged people, but if you want to send a "
"message which includes tagging someone, use the format <@display name>. Just tag in the message you "
"are writing and enclose it in <>. For example, if you want to tag @bhattu2, write <@bhattu2>.```"
)
else:
tag_group(user, channel, list(set(positions)), message) # tagging the group
except SlackApiError as e:
# sending the error message if the group name is not valid
client.chat_postEphemeral(
channel=channel,
user=user,
text=f"Hey <@{user}>!\n"
f"I don't know what you mean by {', '.join(undefined)}\n"
"```Usage:\n"
"/tag <groups, (comma seperated. !! do not give spaces)> <message>\n"
"/tag <groups, (comma seperated. !! do not give spaces)> (In this case, message will be 'Tagged "
"you')\n\n"
"Groups:\n"
"- ctm | ctms | fresher | freshers\n"
"- exec | execs | executive | executives\n"
"- adv | advisor | advisors\n\n"
"Message:\n"
"The message can be anything you want to send to the tagged people, but if you want to send a "
"message which includes tagging someone, use the format <@display name>. Just tag in the message you "
"are writing and enclose it in <>. For example, if you want to tag @bhattu2, write <@bhattu2>.```"
f"An error occurred: {e.response['error']}"
)
else:
tag_group(user, channel, list(set(positions)), message) # tagging the group

return response, 200

Expand Down Expand Up @@ -570,11 +581,11 @@ def bhattu_mod():
return Response(), 200


@app.route('/health', methods=['GET'])
def health():
print("Health check")
return Response(), 200


if __name__ == '__main__':
while True:
try:
scheduler = threading.Thread(target=ping_scheduler)
scheduler.start()
app.run(host="0.0.0.0", port=8080)
except Exception as e:
print(e)
app.run(host="0.0.0.0", port=8080)
133 changes: 131 additions & 2 deletions data.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ctm": [],
"exec": [
"23": [],
"22": [
{
"id": "U05B0LX9C5C",
"name": "yoganshsharma65",
Expand Down Expand Up @@ -143,5 +143,134 @@
"name": "rajivharlalka009",
"real_name": "Rajiv Harlalka"
}
],
"21": [
{
"id": "U03M94DCATZ",
"name": "jeffrey.samuel",
"real_name": "Jeffrey Samuel"
},
{
"id": "U03MH4428ES",
"name": "yk553",
"real_name": "Karthikeya"
},
{
"id": "U03MLQ91VJ9",
"name": "proffapt",
"real_name": "Arpit Bhardwaj"
},
{
"id": "U03MLQ95GKF",
"name": "ashprasanth2003",
"real_name": "Ashwin Prasanth"
},
{
"id": "U03MLQ9CUBX",
"name": "shadowwarriorpro3003",
"real_name": "Harsh Khandeparkar"
},
{
"id": "U03MLQ9FNQM",
"name": "shreyansh.yashi",
"real_name": "Shreyansh"
},
{
"id": "U03MLQ9K3S9",
"name": "sarikabishnoi",
"real_name": "Sarika Bishnoi"
},
{
"id": "U03MPLC273M",
"name": "soumilirupsa2020",
"real_name": "Soumili Mukherjee"
},
{
"id": "U03MS4HB5M2",
"name": "bajaj.ishaan09",
"real_name": "Ishaan Bajaj"
},
{
"id": "U03MS4HLEA0",
"name": "somyakumar958",
"real_name": "Somya"
},
{
"id": "U03NDEQTQKA",
"name": "therohan84",
"real_name": "Rohan Barsagade"
}
],
"20": [
{
"id": "U026LPNJW8P",
"name": "sohamsendev",
"real_name": "Soham sen"
},
{
"id": "U026UNXGV8W",
"name": "atharvaamritkar0",
"real_name": "Atharva Amritkar"
},
{
"id": "U026YETJ6F7",
"name": "adityamishra",
"real_name": "Aditya Mishra"
},
{
"id": "U026YETKH1T",
"name": "aayushmannitish1",
"real_name": "Nitish Kumar"
},
{
"id": "U0271FGSRR8",
"name": "adiboy_3112",
"real_name": "Aditya Ranjan Jha"
},
{
"id": "U0271MHDXNX",
"name": "sheharyaar48",
"real_name": "Mohammad Shehar Yaar Tausif"
},
{
"id": "U0271MHF683",
"name": "utsavmehta2002",
"real_name": "Utsav Mehta"
},
{
"id": "U0277MFMWJG",
"name": "agarwalikshita13",
"real_name": "Ikshita Agarwal"
},
{
"id": "U0277MFP51S",
"name": "sneaky-potato",
"real_name": "Ashwani Kumar Kamal"
},
{
"id": "U027E5EPDSM",
"name": "cghosh828049",
"real_name": "Chirag Ghosh"
},
{
"id": "U027E5EQZ8R",
"name": "mallikritwik2014",
"real_name": "Ritwik Ranjan Mallik"
},
{
"id": "U027E5ESETT",
"name": "rajivharlalka009",
"real_name": "Rajiv Harlalka"
},
{
"id": "U027R6DLE0G",
"name": "ishanmanchanda70",
"real_name": "Ishan Manchanda"
},
{
"id": "U027R6DMS64",
"name": "likhithsaiganesh0",
"real_name": "Likhith Sai Ganesh"
}
]
}

0 comments on commit 8bcbd22

Please sign in to comment.