2 lines
6.3 KiB
JSON
2 lines
6.3 KiB
JSON
|
|
{"id":"chatcmpl-9e52cd160b64f73b","object":"chat.completion","created":1774197640,"model":"NousResearch\/Hermes-3-Llama-3.2-3B","choices":[{"index":0,"message":{"role":"assistant","content":"First, install the required dependencies:\n\n```\npip install python-slack-sdk\npip install sendgrid\npip install google-api-python-client\npip install pygithub3\n```\n\nHere is the complete integration code:\n\n```python\nimport os\nfrom slack_sdk import WebClient\nfrom sendgrid import SendGridAPIClient\nfrom google.oauth2.credentials import Credentials\nfrom googleapiclient.discovery import build\nfrom github3 import Github\n\nclass TaskManagerCLI:\n # ... (rest of the code)\n\n def slack_notification(self, message):\n slack_token = os.environ.get('SLACK_BOT_TOKEN')\n slack_client = WebClient(token=slack_token)\n slack_client.chat_postMessage(channel='#task-manager', text=message)\n\n def sendgrid_notification(self, message):\n sendgrid_api_key = os.environ.get('SENDGRID_API_KEY')\n message = {\n \"personalizations\": [\n {\n \"to\": [\n {\n \"email\": os.environ.get('USER_EMAIL')\n }\n ]\n }\n ],\n \"from\": {\n \"email\": os.environ.get('SENDGRID_FROM_EMAIL')\n },\n \"subject\": \"Task Manager Notification\",\n \"text\": message\n }\n try:\n sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))\n response = sg.client.mail.send.post(request_body=message)\n print(response.status_code)\n print(response.body)\n except Exception as e:\n print(f\"Something went wrong with the SendGrid notification: {e}\")\n\n def google_calendar_sync(self):\n credentials = Credentials.from_authorized_user_file('credentials.json', ['https:\/\/www.googleapis.com\/auth\/calendar'])\n google_calendar_service = build('calendar', 'v3', credentials=credentials)\n calendar_id = 'primary'\n now = datetime.now().isoformat()\n for task in self.task_manager.tasks:\n if task.due_date and task.due_date < now:\n event = {\n 'summary': f\"{task.title} - Due: {task.due_date}\",\n 'start': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'end': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'reminders': {\n 'useDefault': False,\n 'overrides': [\n {'method': 'email', 'minutes': 24 * 60},\n {'method': 'popup', 'minutes': 10}\n ],\n 'notifyDays': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']\n }\n }\n event = google_calendar_service.events().insert(calendarId=calendar_id, body=event).execute()\n print(f\"Event created: {event.get('htmlLink')}\")\n elif task.due_date and task.due_date > now:\n event = {\n 'summary': f\"{task.title} - Upcoming\",\n 'start': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'end': {'dateTime': task.due_date, 'timeZone': 'UTC'},\n 'reminders': {\n 'useDefault': False,\n 'overrides': [\n {'method': 'email', 'minutes': 24 * 60},\n {'method': 'popup', 'minutes': 10}\n ],\n 'notifyDays': ['monday', 'tuesday', 'wednesday', 'thursday', 'friday']\n }\n }\n event = google_calendar_service.events().insert(calendarId=calendar_id, body=event).execute()\n print(f\"Event created: {event.get('htmlLink')}\")\n\n def github_issue(self):\n githu
|