This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment check and cleanup script
- Loading branch information
Showing
2 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import argparse | ||
|
||
import keyring | ||
|
||
from clubhouse import ClubhouseClient | ||
|
||
|
||
def delete_comment(start, end, message): | ||
global story_id, comment | ||
c = ClubhouseClient(keyring.get_password('alloy', 'clubhouse')) | ||
for story_id in range(start, end): | ||
print(f"Checking story {story_id}") | ||
comments = c.get('stories', story_id).get('comments') | ||
if not comments: | ||
continue | ||
for comment in comments: | ||
if comment['text'].startswith(message): | ||
print(f"Deleting comment {comment['id']} from story {story_id}") | ||
c.delete("stories", story_id, 'comments', comment['id']) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description="") | ||
parser.add_argument('start', help="First story id to check") | ||
parser.add_argument('end', help="Last story id to check") | ||
parser.add_argument('message', | ||
help="Last story id to check", | ||
default='The task moved to https://app.clubhouse.io/') | ||
args = parser.parse_args() | ||
|
||
delete_comment(args.start, args.end, args.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters