6 * inputs, perform calculations, and provide outputs. Functions can
7 * be used independently or as steps in workflows.
8 * https://api.slack.com/automation/functions/custom
9 */
10export const SampleFunctionDefinition = DefineFunction({
41 * definition (see above), as well as a function that contains
42 * handler logic that's run when the function is executed.
43 * https://api.slack.com/automation/functions/custom
44 */
45export default SlackFunction(
49
50 // inputs.user is set from the interactivity_context defined in sample_trigger.ts
51 // https://api.slack.com/automation/forms#add-interactivity
52 const updatedMsg = `:wave: ` + `<@${inputs.user}>`
53 + ` submitted the following message: \n\n>${inputs.message}`;
60
61 // Save the sample object to the datastore
62 // https://api.slack.com/automation/datastores
63 const putResponse = await client.apps.datastore.put({
64 datastore: "SampleObjects",
4 * Datastores are a Slack-hosted location to store
5 * and retrieve data for your app.
6 * https://api.slack.com/automation/datastores
7 */
8const SampleObjectDatastore = DefineDatastore({
327
328// ============================================================
329// TELEGRAM API INTERACTION
330// ============================================================
331
332/**
333 * Send a message using the Telegram API
334 */
335async function sendTelegramMessage(chatId, text) {
337 const botToken = process.env.TELEGRAM_BOT_TOKEN;
338
339 const response = await fetch(`https://api.telegram.org/bot${botToken}/sendMessage`, {
340 method: "POST",
341 headers: { "Content-Type": "application/json" },
367 const botToken = process.env.TELEGRAM_BOT_TOKEN;
368
369 const response = await fetch(`https://api.telegram.org/bot${botToken}/setWebhook`, {
370 method: "POST",
371 headers: { "Content-Type": "application/json" },
391 const botToken = process.env.TELEGRAM_BOT_TOKEN;
392
393 const response = await fetch(`https://api.telegram.org/bot${botToken}/getWebhookInfo`);
394 const result = await response.json();
395 return result;
10
11 // Look up the user's location from their IP
12 const geoResponse = await fetch(`http://ip-api.com/json/${ip}`);
13 const geoData = await geoResponse.json();
14
26 <style>
27 {`
28 @import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');
29 body { font-family: 'Share Tech Mono', monospace; background: #0a0a0a; color: #00ff00; }
30 .glow { text-shadow: 0 0 10px #00ff00; }
44}
45
46// Helper for Discord API requests
47async function discordRequest(endpoint: string, options: any = {}) {
48 const url = `https://discord.com/api/v10/${endpoint}`;
49 const headers = {
50 Authorization: `Bot ${Deno.env.get("DISCORD_BOT_TOKEN")}`,
63 if (!res.ok) {
64 const error = await res.json();
65 console.error(`❌ Discord API error: ${res.status}`, error);
66 throw new Error(`Discord API error: ${res.status} ${error.message}`);
67 }
68
106 console.log(`📤 Sending follow-up message: ${content}`);
107 try {
108 await fetch(`https://discord.com/api/v10/webhooks/${applicationId}/${interactionToken}/messages/@original`, {
109 method: "PATCH",
110 headers: {
2import fetch from "node:node-fetch"; // Ensure this is installed if not already
3import process from "node:process";
4import { BskyAgent } from "npm:@atproto/api";
5
6// Create a Bluesky Agent
57 : `applications/${DISCORD_APP_ID}/commands`;
58
59 console.log(`📡 Using API endpoint: ${endpoint}`);
60
61 try {
65
66 // Register the commands
67 const response = await fetch(`https://discord.com/api/v10/${endpoint}`, {
68 method: "PUT",
69 headers: {
18 finish_reason?: string;
19 num_images?: number;
20 our_api_token: boolean;
21}
22
43 finish_reason TEXT,
44 num_images INTEGER,
45 our_api_token INTEGER NOT NULL,
46 finish_timestamp INTEGER
47 )
2import { useAuth } from "./useAuth.tsx";
3
4const PROJECT_ENDPOINT = "/api/project";
5const FILES_ENDPOINT = "/api/project-files";
6
7export function useProject (projectId: string, branchId?: string) {
2import { useAuth } from "./useAuth.tsx";
3
4const ENDPOINT = "/api/projects-loader";
5
6export function useProjects () {