4import { EyeIcon, FileCode2Icon, SparklesIcon, SquarePenIcon } from "./icons.tsx";
56export function Home() {
7return (
8<div className="container">
TownieLoginRoute.tsx1 match
4import { useAuth } from "../hooks/useAuth.tsx";
56export function LoginRoute() {
7const navigate = useNavigate();
8const { isAuthenticated, authenticate, error } = useAuth();
testPondiverseaddCreation1 match
4import { TABLE_NAME } from "./updateTable";
56export default async function(req: Request): Promise<Response> {
7// body contains:
8// - title (string)
testPondiverseupdateTable1 match
23export const TABLE_NAME = "pondiverse_creations_v4";
4export default async function(req: Request): Promise<Response> {
5let body;
6try {
telegramBotStarterindex.ts14 matches
1// ============================================================
2// CORE FUNCTIONALITY
3// ============================================================
4import sendTelegramMessage from "https://esm.town/v/asdfg/telegramBotStarter/sendTelegramMessage.tsx";
7* Expose this as an HTTP endpoint in Val.town
8*/
9export default async function handleTelegramWebhook(req) {
10try {
11// Ensure the request is a POST request
74* Process commands from the owner
75*/
76async function processOwnerCommand(message) {
77const text = message.text || "";
78199* Get information about a user
200*/
201async function getUserInfo(userId) {
202return await DB.get(`userInfo:${userId}`);
203}
206* Get list of all active users who have messaged the bot
207*/
208async function getActiveUsers() {
209const keys = await DB.list({ prefix: "userInfo:" });
210const users = [];
222* Get list of blocked user IDs
223*/
224async function getBlockedUsers() {
225return await DB.get("blockedUsers") || [];
226}
229* Block a user
230*/
231async function blockUser(userId) {
232const blockedUsers = await getBlockedUsers();
233userId = userId.toString();
244* Unblock a user
245*/
246async function unblockUser(userId) {
247const blockedUsers = await getBlockedUsers();
248userId = userId.toString();
264* Store a message in the database
265*/
266async function storeMessage(userId, userName, text, direction) {
267const messages = await getMessages(userId) || [];
268291* Get message history for a specific user
292*/
293async function getMessages(userId) {
294return await DB.get(`messages:${userId}`) || [];
295}
298* Notify the owner about new incoming messages
299*/
300async function notifyOwner(userId, userName, messageText) {
301const ownerChatId = process.env.OWNER_CHAT_ID;
302311* Reply to a specific user
312*/
313async function replyToUser(userId, text) {
314// Send the message to the user
315const success = await sendTelegramMessage(userId, text);
343344// ============================================================
345// SETUP FUNCTIONS
346// ============================================================
347350* Use this once during initial setup
351*/
352export async function setupWebhook(webhookUrl) {
353try {
354const botToken = process.env.TELEGRAM_BOT_TOKEN;
telegramBotStartertestBot.tsx2 matches
5import { sendTelegramMessage } from "https://esm.town/v/asdfg/telegramBotStarter/sendTelegramMessage.tsx";
67async function testBot() {
8const ownerChatId = process.env.OWNER_CHAT_ID;
926}
2728// console log testBot function
29console.log(await testBot);
3* Requires a Telegram Bot token as an environment variable
4*/
5export async function sendTelegramMessage(chatId: string, message: string) {
6const botToken = Deno.env.get('TELEGRAM_BOT_TOKEN');
7
Townieusage-dashboard.ts4 matches
45// Basic Auth middleware
6async function basicAuthMiddleware(req: Request): Promise<Response | null> {
7const realm = "Usage Dashboard";
8const unauthorizedResponse = new Response("Unauthorized", {
50}
5152export default async function(req: Request) {
53// Check authentication first
54const authResponse = await basicAuthMiddleware(req);
286287<script>
288document.addEventListener('DOMContentLoaded', function() {
289// Add click event listeners to all tabs
290document.querySelectorAll('.tab').forEach(tab => {
291tab.addEventListener('click', function() {
292const tabId = this.getAttribute('data-tab');
293
Townieschema.tsx2 matches
20}
2122async function createTables() {
23await sqlite.execute(`
24CREATE TABLE IF NOT EXISTS ${USAGE_TABLE} (
42}
4344async function deleteTables() {
45await sqlite.execute(`DROP TABLE IF EXISTS ${USAGE_TABLE}`);
46}
Towniequeries.tsx4 matches
7// but in the meantime, we can cache user info in memory
8const userIdCache: { [key: string]: any } = {};
9export async function getUser(bearerToken: string) {
10if (userIdCache[bearerToken]) return userIdCache[bearerToken];
1116}
1718async function last24Hours(userId: string) {
19const usage = await sqlite.execute(
20`SELECT
37const DAILY_PRO_LIMIT = 5; // $5 per day
3839export async function overLimit(bearerToken: string) {
40const user = await getUser(bearerToken);
41const last24HourUsage = await last24Hours(user.id);
44}
4546export async function trackUsage({
47bearerToken,
48val_id,