11interface RedditSearchOptions {
12 query: string;
13 apiKey?: string;
14}
15
17export async function redditSearch({
18 query,
19 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
20}: RedditSearchOptions): Promise<ThreadResult[]> {
21 if (!apiKey) {
22 throw new Error("BrowserBase API key is required");
23 }
24
25 const puppeteer = new PuppeteerDeno({ productName: "chrome" });
26 const browser = await puppeteer.connect({
27 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}&enableProxy=true`,
28 ignoreHTTPSErrors: true,
29 });
54 query: topic,
55 pages: 2,
56 apiKey: Deno.env.get("BROWSERBASE_API_KEY") ?? "",
57 });
58}
63 maxResults: 10,
64 daysBack: 1,
65 apiKey: Deno.env.get("TWITTER_BEARER_TOKEN") ?? "",
66 });
67}
98
99 if (!response.ok) {
100 throw new Error(`Slack API error: ${response.status} ${response.statusText}`);
101 }
102
9});
10
11const client = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
12
13async function main() {
1This is a simple script to create a post on Campsite. Use it as a starting point for other scripts.
2
3Campsite API Documentation: https://campsite.com/docs
36 maxResults = 4,
37 daysBack = 1,
38 apiKey,
39}: {
40 query: string;
41 maxResults?: number;
42 daysBack?: number;
43 apiKey: string;
44}): Promise<Website[]> {
45 const startDate = new Date();
46 startDate.setDate(startDate.getDate() - daysBack);
47
48 // Ensure the query is properly formatted for the Twitter API
49 const formattedQuery = encodeURIComponent(`${query} -is:retweet lang:en`);
50
53 console.log(`Searching Twitter for query: "${query}", start date: ${startDate.toISOString()}`);
54 const res = await twitterJSON({
55 url: `https://api.twitter.com/2/tweets/search/recent?query=${formattedQuery}&${await searchParams(
56 {
57 start_time: startDate.toISOString(),
63 },
64 )}`,
65 bearerToken: apiKey,
66 });
67 if (res.errors) {
95 const authorResponse = await twitterUser({
96 id: tweet.author_id,
97 bearerToken: apiKey,
98 });
99 author = authorResponse.data;
1This val creates a GitHub webhook listener that posts pull request information to Campsite when a pull request is opened or closed.
2
3Campsite API docs: https://campsite.com/docs
3Learn about how we run our async standups on Campsite: https://www.campsite.com/blog/effective-daily-standups-for-distributed-teams
4
5Campsite API Documentation: https://campsite.com/docs
12 query = "Artificial Intelligence",
13 pages = 3,
14 apiKey = Deno.env.get("BROWSERBASE_API_KEY"),
15}: {
16 query?: string;
17 pages?: number;
18 apiKey: string;
19}): Promise<Website[]> {
20 let browser;
27 console.log("Connecting to BrowserBase...");
28 browser = await puppeteer.connect({
29 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${apiKey}`,
30 ignoreHTTPSErrors: true,
31 });
64 let hasMorePages = true;
65 for (let i = 1; i <= pages && hasMorePages; i++) {
66 console.info(`Scraping page ${i}...`);
67 let pageThreads = await scrapePageThreads(page);
68 allThreads = [...allThreads, ...pageThreads];
15 bgColor?: string;
16 font?: string;
17 api_base?: string;
18}
19
25 bgColor,
26 font,
27 api_base,
28}: MicroReactProps) {
29 const baseUrl = "https://microreact.glitch.me/embed/index.html";
37 if (bgColor) params.append("bgColor", encodeURIComponent(bgColor));
38 if (font) params.append("font", encodeURIComponent(font));
39 if (api_base) params.append("api_base", api_base);
40
41 const iframeSrc = `${baseUrl}?${params.toString()}`;
9 // Verify this webhook came from our bot
10 if (
11 req.headers.get("x-telegram-bot-api-secret-token")
12 !== Deno.env.get("telegramWebhookSecret")
13 ) {