Skip to content

Commit e4953e6

Browse files
authored
Merge pull request #241 from OpenToAllCTF/fix_archive
Fix mistakenly removed functions
2 parents 4ce0d16 + dccde9b commit e4953e6

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

handlers/challenge_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def execute(cls, slack_wrapper, args, timestamp, channel_id, user_id, user_is_ad
406406
raise InvalidCommand("This challenge does not exist.")
407407

408408
# Remove the challenge channel and ctf challenge entry
409-
slack_wrapper.archive_private_channel(challenge.channel_id)
409+
slack_wrapper.archive_channel(challenge.channel_id)
410410
remove_challenge_by_channel_id(ChallengeHandler.DB, challenge.channel_id, ctf.channel_id)
411411

412412
# Show confirmation message

tests/slackwrapper_mock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def get_private_channels(self):
116116
"""Fetch all private channels in which the user participates."""
117117
return json.loads(self.get_private_channels_response)
118118

119-
def archive_private_channel(self, channel_id):
120-
"""Archive a private channel"""
119+
def archive_channel(self, channel_id):
120+
"""Archive a public or private channel."""
121121
# TODO: The git handler must be mocked before testing archive command to avoid uploading test cases
122122
pass
123123

util/slack_wrapper.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,8 @@ def get_private_channels(self) -> List[Dict]:
182182

183183
return self.get_channels(types="private_channel")
184184

185-
def archive_private_channel(self, channel_id: str) -> Dict:
186-
"""Archive a private channel"""
187-
188-
return self.client.conversations_archive(channel=channel_id).data
189-
190-
def archive_public_channel(self, channel_id: str) -> Dict:
191-
"""Archive a public channel"""
185+
def archive_channel(self, channel_id: str) -> Dict:
186+
"""Archive a public or private channel."""
192187

193188
return self.client.conversations_archive(channel=channel_id).data
194189

@@ -213,3 +208,10 @@ def remove_reminders_by_text(self, text: str):
213208
for reminder in reminders.get("reminders", []):
214209
if text in reminder["text"]:
215210
self.remove_reminder(reminder["id"])
211+
212+
def get_channel_by_name(self, name):
213+
"""Fetch a channel with a given name."""
214+
channels = self.get_channels(types="public_channel,private_channel")
215+
for channel in channels:
216+
if channel['name'] == name:
217+
return channel

0 commit comments

Comments
 (0)