56// রেফার ও ব্যালেন্স ডাটাবেজ ফাংশন
7async function getReferCount(user_id: number) {
8return (await get(`refer_${user_id}`)) || 0;
9}
1011async function addRefer(user_id: number) {
12const current = await getReferCount(user_id);
13await set(`refer_${user_id}`, current + 1);
14}
1516async function getBalance(user_id: number) {
17return (await get(`balance_${user_id}`)) || 0;
18}
1920async function addBalance(user_id: number, amount: number) {
21const current = await getBalance(user_id);
22await set(`balance_${user_id}`, current + amount);
23}
2425export default async function(req: Request): Promise<Response> {
26const { message } = await req.json();
27if (!message) return new Response("No message found");
131132// ✅ মেসেজ পাঠানো ফাংশন
133async function sendMessage(chat_id: number, text: string, reply_markup: any = null) {
134await fetch(`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`, {
135method: "POST",
table-mountain-status-cronmain.tsx2 matches
1import { createClient } from "https://esm.sh/@libsql/client@0.6.0";
23async function main() {
4const response = await fetch(
5"https://cms.tablemountain.net/admin/actions/submissions/default/weather-api",
27}
2829export default async function(interval: Interval) {
30await main();
31}
2import type { ReactNode } from "npm:react@18.2.0";
34export function Layout({ children }: { children: ReactNode }) {
5return (
6<html lang="en">
markdownBlogStarterindex.tsx3 matches
5import { Layout } from "./Layout.tsx";
67function PostComponent({ markdown, link }: { markdown: string; link?: string }) {
8return (
9<div style={{ border: "1px solid gray", padding: "10px", marginBottom: "20px", borderRadius: "5px" }}>
14}
1516export default async function(req: Request): Promise<Response> {
17const url = new URL(req.url);
18if (url.pathname === "/") {
44}
4546function html(children: React.ReactNode) {
47return new Response(
48renderToString(
reactHonoStarterindex.ts3 matches
218</div>
219<script>
220function getIcon(iconName) {
221const icons = { 'gear': '⚙️', 'crosshairs': '🎯', 'map': '🗺️', 'calculator': '🧮' };
222return icons[iconName] || '🔧';
223}
224225function calculateDamage() {
226const health = parseInt(document.getElementById('health-input').value) || 0;
227const damage = health > 0 ? Math.min(health, 50) : 0;
244export default app.fetch;
245246function getIcon(iconName: string): string {
247const icons = { "gear": "⚙️", "crosshairs": "🎯", "map": "🗺️", "calculator": "🧮" };
248return icons[iconName] || "🔧";
proxydatasaver.ts21 matches
45// =============================================================================
4647function formatBytes(bytes: number): string {
48if (bytes === 0) return "0 B";
49const k = 1024;
53}
5455async function getGzippedSize(text: string): Promise<number> {
56if (!text) return 0;
57try {
83// =============================================================================
8485function generateHtmlTemplate(
86article: Article,
87targetUrl: string,
145</main>
146<script>
147(function() {
148const url = new URL(window.location);
149const actualMode = '${sizeInfo.processingMode}';
158}
159160function generateMetaInfo(
161targetUrl: string,
162sizeInfo: SizeInfo,
199}
200201function generateHomePage(): string {
202return `<!DOCTYPE html>
203<html lang="en">
245* Makes a URL absolute if it's relative
246*/
247function makeAbsoluteUrl(href: string, baseUrl: string): string {
248if (!href || !baseUrl.startsWith("http")) {
249return href;
267* Converts a URL to go through the datasaver proxy
268*/
269function createProxyUrl(url: string, originalRequestUrl: string): string {
270const params = new URLSearchParams();
271params.set("_url", url);
289* Removes all JavaScript from HTML content
290*/
291function removeJavaScript(content: string): string {
292// Remove <script> tags and their content
293content = content.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "");
315* Processes HTML content to fix URLs and optionally remove JavaScript
316*/
317function processContent(
318content: string,
319baseUrl: string,
370* Extracts basic metadata (title, description) from HTML
371*/
372function extractBasicMetadata(html: string): {
373title: string;
374excerpt: string;
388* Extracts body content from HTML, with fallback to full content
389*/
390function extractBodyContent(html: string): string {
391const bodyMatch = html.match(/<body[^>]*>([\s\S]*?)<\/body>/i);
392if (bodyMatch) {
401* High-optimization article extraction using Readability
402*/
403function extractArticle(
404html: string,
405url: string,
446* Medium-optimization extraction: preserves layout, removes JS
447*/
448function extractStatic(
449html: string,
450url: string,
498* Low-optimization extraction: preserves JS for interactivity
499*/
500function extractDynamic(
501html: string,
502url: string,
550* Determines optimal processing mode based on content analysis
551*/
552function determineProcessingMode(
553html: string,
554url: string,
689* Extracts and processes content based on determined mode
690*/
691function extractContent(
692html: string,
693url: string,
748* Calculates size information for the processed content
749*/
750async function calculateSizeInfo(
751originalHtml: string,
752contentLength: number,
782* Fetches content from the target URL
783*/
784async function fetchContent(
785targetUrl: string,
786requestHeaders: Headers,
842843/**
844* Main datasaver function
845*
846* @param _url - Required. The URL to fetch and optimize
852* @param _debug - Optional. Enables debug logging
853*/
854export default async function(req: Request): Promise<Response> {
855if (req.method !== "GET") {
856return new Response("Method not allowed", { status: 405 });
89/** @param {Interval} interval */
10export async function cronValHandler(interval: any) {
11console.log("⏰ Cron fired at", new Date(interval.lastRunAt).toISOString());
12
qkwen02_http.tsx1 match
1export default async function httpHandler(req: Request) {
2try {
3const targetUrl = new URL(req.url).searchParams.get("url");
personal_trmnlmain.tsx1 match
1import { sqlite } from "https://esm.town/v/std/sqlite";
23export default async function handler(_: Request): Promise<Response> {
4const res = await sqlite.execute({
5sql: `SELECT summary, updated FROM manifold_cache WHERE key = ?`,
weather-aimain.tsx16 matches
11}
1213async function getWeather(latitude: number, longitude: number): Promise<WeatherData> {
14console.log(`[getWeather] Fetching weather for lat: ${latitude}, lon: ${longitude}`);
15const url =
26}
2728async function getCoordinates(locationName: string): Promise<Coordinates> {
29console.log(`[getCoordinates] Looking up: ${locationName}`);
3077}
7879async function callOpenAI(messages: any[], tools: any[]) {
80const OPENAI_API_KEY = Deno.env.get("OPENAI_API_KEY");
8196}
9798async function processWeatherRequest(location: string) {
99console.log(`[processWeatherRequest] Starting weather lookup for: ${location}`);
100const tools = [
101{
102type: "function",
103function: {
104name: "get_coordinates",
105description: "Get latitude and longitude coordinates for a given location name.",
116},
117{
118type: "function",
119function: {
120name: "get_weather",
121description: "Get current temperature for provided coordinates in celsius.",
152153for (const toolCall of completion.choices[0].message.tool_calls) {
154const name = toolCall.function.name;
155const args = JSON.parse(toolCall.function.arguments);
156157console.log(`[processWeatherRequest] Calling function: ${name} with args:`, args);
158159let result;
166}
167168console.log(`[processWeatherRequest] Function ${name} result:`, result);
169170messages.push({
196<meta charset="UTF-8">
197<meta name="viewport" content="width=device-width, initial-scale=1.0">
198<title>Weather Function Calling Demo</title>
199<style>
200body {
279<body>
280<div class="container">
281<h1>🌤️ Weather Lookup with Function Calling</h1>
282<div class="input-group">
283<input
293294<script>
295async function getWeather() {
296const location = document.getElementById('location').value;
297const resultDiv = document.getElementById('result');
346`;
347348export default async function handler(req: Request): Promise<Response> {
349// Handle GET request - serve the HTML page
350if (req.method === "GET") {