growingEmeraldGrasshoppermain.tsx6 matches
4import React, { useEffect, useRef, useState } from "https://esm.sh/react@18.2.0";
56const ELEVENLABS_API_KEY = "sk_352c51c19a910aa3973cc146d057c11a1216da0eec41e0ee";
7const ELON_VOICE_ID = "UgBBYS2sOqTuMpoF3BR0"; // Specific Elon Musk voice ID
860try {
61for (const chunk of chunks) {
62const response = await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${ELON_VOICE_ID}`, {
63method: "POST",
64headers: {
65"Content-Type": "application/json",
66"xi-api-key": ELEVENLABS_API_KEY,
67},
68body: JSON.stringify({
161setError(error.message);
162163// Fallback response if API fails
164const fallbackResponse = {
165role: "Character",
424try {
425const openai = new OpenAI({
426apiKey:
427"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",
428});
432console.log("Received messages:", JSON.stringify(messages, null, 2));
433434// Prepare messages for OpenAI API
435const formattedMessages = [
436{ role: "system", content: CHARACTER_DESCRIPTION },
4export default async function handleCron(interval) {
5const following = await fetchCookie(
6"https://www.instagram.com/api/v1/friendships/375942300/following/?query=miguelse10",
7{
8method: "GET",
82831. **Create a Slack App**:
84- Go to [Slack API Apps](https://api.slack.com/apps) โ Create New App โ From scratch
85- Name your app and select your workspace
86- Click "Create App"
137138try {
139const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
140141const response = await fetch(url, {
166}
167} catch (error) {
168console.error("Exception during API call:", error);
169return { success: false, message: error.message };
170}
162}
163164const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
165166const response = await fetch(url, {
195196try {
197const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
198199const response = await fetch(url, {
32};
3334// Types for Slack API
35type SlackMessage = {
36blocks: any[];
219220// Get PR details
221const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
222223let response;
241return await response.json();
242} catch (jsonError) {
243throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
244}
245}
246247// Merge a PR via GitHub API
248async function mergePR(repo: string, prNumber: number) {
249const token = Deno.env.get("GITHUB_TOKEN");
282283// Proceed with merge
284const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
285286const response = await fetch(url, {
99100try {
101const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
102103const response = await fetch(url, {
132}
133} catch (error) {
134console.error("Exception during API call:", error);
135return { success: false, message: error.message };
136}
129130try {
131const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/assignees`;
132console.log("๐ Sending assignee request to:", url);
133145});
146147console.log("๐ GitHub API response status:", response.status);
148149if (response.ok) {
155try {
156const error = await response.json();
157console.error("โ GitHub API error:", JSON.stringify(error));
158errorMessage = error.message || errorMessage;
159168} catch (e) {
169const errorText = await response.text();
170console.error("โ GitHub API error text:", errorText);
171}
172return { success: false, message: errorMessage };
173}
174} catch (error) {
175console.error("โ Exception during API call:", error);
176return { success: false, message: error.message };
177}
34};
3536// Types for Slack API
37type SlackMessage = {
38blocks: any[];
323324// Get PR details
325const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}`;
326console.log("๐ Fetching from GitHub API URL:", url);
327328let response;
335},
336});
337console.log("๐ GitHub API response received");
338console.log("๐ Response status:", response.status);
339console.log("๐ Response status text:", response.statusText);
346347if (!response.ok) {
348console.error(`โ GitHub API error: ${response.status} ${response.statusText}`);
349350let errorText;
351try {
352errorText = await response.text();
353console.error("โ GitHub API error response:", errorText);
354355try {
356// Try to parse as JSON for more details
357const errorJson = JSON.parse(errorText);
358console.error("โ GitHub API error details:", JSON.stringify(errorJson));
359} catch (e) {
360// Not JSON, that's fine
370try {
371data = await response.json();
372console.log("๐ Successfully parsed GitHub API response");
373} catch (jsonError) {
374console.error("โ Failed to parse GitHub API response:", jsonError);
375376try {
384}
385386throw new Error(`Failed to parse GitHub API response: ${jsonError.message}`);
387}
388400}
401402// Merge a PR via GitHub API
403async function mergePR(repo: string, prNumber: number) {
404console.log(`๐ Starting mergePR for PR #${prNumber} in ${repo}`);
448449// Proceed with merge
450const url = `https://api.github.com/repos/${repo}/pulls/${prNumber}/merge`;
451console.log("๐ Sending merge request to:", url);
452468body: mergeBody,
469});
470console.log("๐ Merge API response received");
471console.log("๐ Response status:", response.status);
472console.log("๐ Response status text:", response.statusText);
638body: JSON.stringify(message),
639});
640console.log("๐ Slack API response received");
641console.log("๐ Response status:", response.status);
642console.log("๐ Response status text:", response.statusText);
649650if (!response.ok) {
651console.error(`โ Slack API error: ${response.status} ${response.statusText}`);
652653let errorText;
654try {
655errorText = await response.text();
656console.error("โ Slack API error response:", errorText);
657} catch (e) {
658console.error("โ Could not read error response:", e);
198}
199200const url = `https://api.github.com/repos/${repo}/issues/${issueNumber}`;
201console.log("๐ Fetching issue from:", url);
202209});
210211console.log("๐ GitHub API response status:", response.status);
212213if (!response.ok) {
215try {
216const error = await response.json();
217console.error("โ GitHub API error:", JSON.stringify(error));
218errorMessage = error.message || errorMessage;
219} catch (e) {
220const errorText = await response.text();
221console.error("โ GitHub API error text:", errorText);
222}
223throw new Error(`Failed to fetch issue: ${errorMessage}`);
237238try {
239const url = `https://api.github.com/repos/${repo}/issues/${prNumber}/labels`;
240console.log("๐ Sending labels update request to:", url);
241253});
254255console.log("๐ GitHub API response status:", response.status);
256257if (response.ok) {
264try {
265const error = await response.json();
266console.error("โ GitHub API error:", JSON.stringify(error));
267errorMessage = error.message || errorMessage;
268} catch (e) {
269const errorText = await response.text();
270console.error("โ GitHub API error text:", errorText);
271}
272return { success: false, message: errorMessage };
273}
274} catch (error) {
275console.error("โ Exception during API call:", error);
276return { success: false, message: error.message };
277}