1# Notehub
2
3A set of helper functions for interacting with the Notehub API
4
5Requires `NOTEHUB_CLIENT_ID` and `NOTEHUB_CLIENT_SECRET` [environment variables](https://www.val.town/settings/environment-variables) to be configured.
2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
24 );
25
26export async function telegramSendAudioMessage(chatId: string, audioData: Uint8Array, botToken: string): Promise<void> {
27 const url = `https://api.telegram.org/bot${botToken}/sendAudio`;
28
2
3// Fetches a random joke.
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
4import { DateTime } from "npm:luxon";
5
6async function getLatestCommit(ghUser: string, ghRepo: string, branch: string, client: Octokit)
7{
8 const { data: refData } = await client.rest.git.getRef({
15}
16
17async function createNewTree(
18 ghUser: string,
19 ghRepo: string,
40}
41
42async function createNewCommit(
43 ghUser: string,
44 ghRepo: string,
60}
61
62async function updateBranchRef(
63 owner: string,
64 repo: string,
92 */
93
94export async function valToGH(
95 repo: string, // owner/repo
96 val: string | string[], // user/val
1export function test(){
2 return Math.random();
3}
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
2
3const script = `
4def mapFunction(r, i):
5 v = r * i
6 return v
8x = [1, 2, 3, 4]
9x
10 .map(mapFunction)
11 .filter(r => r * r)
12 .join(",")
2
3const script = `
4def mapFunction(r, i):
5 v = r * i
6 return v
8x = [1, 2, 3, 4]
9x
10 .map(mapFunction)
11 .filter(r => r * r)
12 .join(",")
3 const { jsPython } = await import("npm:jspython-interpreter");
4 const script = `
5def mapFunction(r, i):
6 v = r * i
7 return v
9x = [1, 2, 3, 4]
10x
11 .map(mapFunction)
12 .filter(r => r * r)
13 .join(",")
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.