Repository: internetarchive/openlibrary

Issue:
Update `issue_comment_bot` to run without publishing a digest or updating issues
### Describe the problem that you'd like solved
<!-- A clear and concise description of what you want to happen. -->
Our `new_comment_digest` Github action, which notifies staff of new comments on Gihub issues every day, failed to run for a few days.  This has caused staff to miss a few days' worth of new comments. 

As the script is today, there is no way to re-run the script without both publishing a digest of new comments to Slack and labeling each issue that has a new comment.  This means that we can't run the script to find new comments for the few days that the action wasn't successfully running without relabeling issues which may have already been addressed by staff.

### Proposal & Constraints
<!-- What is the proposed solution / implementation? Is there a precedent of this approach succeeding elsewhere? -->
Add the following:
- Options to prevent the script from publishing a digest to Slack, and to prevent labeling issues on GitHub.  
- A verbose mode, which will print details about each issue with new comments to `stdout`

<!-- Which suggestions or requirements should be considered for how feature needs to appear or be implemented? -->

### Additional context
<!-- Add any other context or screenshots about the feature request here. -->

### Stakeholders
<!-- @ tag stakeholders of this bug -->
@mekarpeles 
@cdrini 
@scottbarnes 


Discussion:

Resolving patch:
diff --git a/scripts/gh_scripts/issue_comment_bot.py b/scripts/gh_scripts/issue_comment_bot.py
--- a/scripts/gh_scripts/issue_comment_bot.py
+++ b/scripts/gh_scripts/issue_comment_bot.py
@@ -3,7 +3,10 @@
 Fetches Open Library GitHub issues that have been commented on
 within some amount of time, in hours.
 
-Writes links to each issue to given Slack channel.
+If called with a Slack token and channel, publishes a digest of
+the issues that were identified to the given channel.
+
+Adds the "Needs: Response" label to the issues in Github.
 """
 import argparse
 import errno
@@ -256,6 +259,18 @@ def add_label_to_issues(issues):
         )
 
 
+def verbose_output(issues):
+    """
+    Prints detailed information about the given issues.
+    """
+    for issue in issues:
+        print(f'Issue #{issue["number"]}:')
+        print(f'\tTitle: {issue["issue_title"]}')
+        print(f'\t{issue["lead_label"]}')
+        print(f'\tCommenter: {issue["commenter"]}')
+        print(f'\tComment URL: {issue["comment_url"]}')
+
+
 def start_job(args: argparse.Namespace):
     """
     Starts the new comment digest job.
@@ -264,9 +279,14 @@ def start_job(args: argparse.Namespace):
     issues = fetch_issues(date_string)
 
     filtered_issues = filter_issues(issues, since)
-    add_label_to_issues(filtered_issues)
-    publish_digest(filtered_issues, args.channel, args.slack_token, args.hours)
-    print('Digest posted to Slack.')
+    if not args.no_labels:
+        add_label_to_issues(filtered_issues)
+        print('Issues labeled as "Needs: Response"')
+    if args.slack_token and args.channel:
+        publish_digest(filtered_issues, args.channel, args.slack_token, args.hours)
+        print('Digest posted to Slack')
+    if args.verbose:
+        verbose_output(filtered_issues)
 
 
 def _get_parser() -> argparse.ArgumentParser:
@@ -281,16 +301,28 @@ def _get_parser() -> argparse.ArgumentParser:
         type=int,
     )
     parser.add_argument(
-        'channel',
+        '-c',
+        '--channel',
         help="Issues will be published to this Slack channel",
         type=str,
     )
     parser.add_argument(
-        'slack_token',
-        metavar='slack-token',
+        '-t',
+        '--slack-token',
         help='Slack auth token',
         type=str,
     )
+    parser.add_argument(
+        '--no-labels',
+        help='Prevent the script from labeling the issues',
+        action='store_true',
+    )
+    parser.add_argument(
+        '-v',
+        '--verbose',
+        help='Print detailed information about the issues that were found',
+        action='store_true',
+    )
 
     return parser
 


Test patch: