11const CREATION_LOCK_KEY = "map_vote_creation_first_half";
1213// Main function that runs as a scheduled val for tallying votes (testing version)
14export default async function() {
15console.log("🧪 TEST MODE: First Half Map Vote Tally Test Job started");
16console.log("⚠️ WARNING: This version skips time verification and is for testing only!");
86const tallyStartTime = Date.now();
8788// Call the map vote tallying function
89const tallyResult = await mapVoteTallying(channelId);
90
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
1314// Main function that runs as a scheduled val for tallying second half votes
15export default async function() {
16console.log("🕒 Second Half Map Vote Tally Cron Job started");
17111const tallyStartTime = Date.now();
112113// Call the map vote tallying function
114const tallyResult = await mapVoteTallying(channelId);
115
12const MINIMUM_VOTING_PERIOD_MS = 3 * 24 * 60 * 60 * 1000; // 3 days in milliseconds
1314// Main function that runs as a scheduled val for tallying votes
15export default async function() {
16console.log("🕒 Map Vote Tally Cron Job started");
17110const tallyStartTime = Date.now();
111112// Call the map vote tallying function
113const tallyResult = await mapVoteTallying(channelId);
114
TowniePreviewFrame.tsx4 matches
9}
1011export function PreviewFrame(props: PreviewProps) {
12const previewKey = useRef<string>("new-chat");
13const [count, setCount] = useState<number>(0);
73const TSRE = /\/$/;
7475function URLInput({ url, pathname, setPathname }) {
76const prefix = url.replace(TSRE, "");
77return (
90}
9192function PreviewSelect({ index, setIndex, files }) {
93return (
94<div>
116}
117118function usePreviewURL({ files }) {
119const [index, setIndex] = useState<number>(0);
120const htmlVals = files?.filter(file => file.links?.endpoint !== undefined);
326this.updateRateLimitFromException(routeKey, retryAfter);
327328// Check if retry time would exceed the function timeout
329const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes (to stay safely under 10 min limit)
330if (retryAfter * 1000 > MAX_WAIT_TIME) {
331console.log(`⚠️ Retry time (${retryAfter}s) would exceed function timeout.`);
332console.log(`Saving state to blob and failing with suggestion to retry later.`);
333336337throw new Error(
338`Rate limit retry time (${retryAfter}s) exceeds function timeout. `
339+ `Please try again later. State has been saved to resume properly.`,
340);
367const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
368if ((this.globalRateLimitUntil - Date.now()) > MAX_WAIT_TIME) {
369console.log(`⚠️ Global rate limit wait time (${waitTime}s) would exceed function timeout.`);
370console.log(`Saving state and failing with suggestion to retry later.`);
371374375throw new Error(
376`Global rate limit wait time (${waitTime}s) exceeds function timeout. `
377+ `Please try again later. State has been saved to resume properly.`,
378);
616console.log(`Rate limit exhausted for route ${routeKey}. Waiting ${waitTimeWithBuffer}ms until reset.`);
617618// Check if wait time would exceed the function timeout
619const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
620if (waitTimeWithBuffer > MAX_WAIT_TIME) {
621console.log(`⚠️ Wait time (${waitTimeWithBuffer}ms) would exceed function timeout.`);
622console.log(`Saving state and failing with suggestion to retry later.`);
623626627throw new Error(
628`Rate limit wait time exceeds function timeout. `
629+ `Please try again later. State has been saved to resume properly.`,
630);
672console.log(`Global rate limit window full. Waiting ${waitTime}ms for a slot to open.`);
673674// Check if wait time would exceed the function timeout
675const MAX_WAIT_TIME = 8 * 60 * 1000; // 8 minutes
676if (waitTime > MAX_WAIT_TIME) {
677console.log(`⚠️ Global rate limit wait time (${waitTime}ms) would exceed function timeout.`);
678console.log(`Saving state and failing with suggestion to retry later.`);
679682683throw new Error(
684`Global rate limit wait time exceeds function timeout. `
685+ `Please try again later. State has been saved to resume properly.`,
686);
692}
693694// Helper function to create a delay
695private delay(ms: number): Promise<void> {
696return new Promise(resolve => setTimeout(resolve, ms));
1112// Calculate days in a month, accounting for leap years
13function getDaysInMonth(year: number, month: number): number {
14return new Date(year, month, 0).getDate();
15}
1617// Format date as MM-DD
18function formatDate(date: Date): string {
19return `${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
20}
2122// Calculate the date range for the second half of current month
23function calculateSecondHalfCurrentMonth(): { startDate: string; endDate: string; rangeText: string } {
24const now = new Date();
25const year = now.getFullYear();
40}
4142// Main function that runs as a scheduled val for second half
43export default async function() {
44console.log("🕒 Second Half Map Vote Cron Job started");
45
1112// Calculate days in a month, accounting for leap years
13function getDaysInMonth(year: number, month: number): number {
14return new Date(year, month, 0).getDate();
15}
1617// Format date as MM-DD
18function formatDate(date: Date): string {
19return `${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
20}
2122// Calculate the date range for the first half of next month
23function calculateFirstHalfNextMonth(): { startDate: string; endDate: string; rangeText: string } {
24const now = new Date();
2546}
4748// Main function that runs as a scheduled val for first half
49export default async function() {
50console.log("🕒 First Half Map Vote Cron Job started");
51
1// Map Vote Channel Creator with enhanced rate limit handling
2// This is the main function that will be scheduled as a cron job
3import { DiscordRateLimitService } from "https://esm.town/v/ktodaz/Discord_Bot_Services/discord-rate-limit-service.tsx";
4import { getAlphabetImageUrls } from "https://esm.town/v/ktodaz/Discord_Bot_Services/map_vote/map-vote-getAlphabetImageUrls.tsx";
44};
4546// Enhanced Discord API request function with rate limiting
47async function discordRequest(endpoint: string, options: RequestInit = {}) {
48const token = Deno.env.get("DISCORD_BOT_TOKEN");
49if (!token) {
102103// Add emoji reaction to message - RATE LIMITED VERSION
104async function addReaction(channelId: string, messageId: string, emoji: string) {
105const routeKey = `/channels/${channelId}/messages/${messageId}/reactions`;
106132}
133134// Helper function to convert color name to integer value
135function getColorFromString(colorName: string): number {
136const colorMap: Record<string, number> = {
137"Red": 0xED4245,
151152// Create the vote channel in Discord
153async function createVoteChannel(config: CurrentConfig, remainder: string = "") {
154try {
155const { DiscordTargets, ApplicationPersonalization } = config;
232233// Send initial placeholder embed
234async function sendInitialEmbed(channel: any, initialEmbedData: InitialVoteCreationEmbedData) {
235try {
236const embed = {
272273// Process variants for a map and add emoji reactions
274async function processMapVariants(messageId: string, channelId: string, map: MapInfo, variantOptions: any) {
275const mapMetaVariants: string[] = [];
276const mapEnabledVariants: string[] = [];
388389// Populate channel with map options and add reactions
390async function populateChannelWithMaps(
391channel: any,
392mapData: HellLetLooseMapData,
459460// Finalize bookend embeds
461async function finalizeBotBookends(
462channel: any,
463initialMessage: any,
569570// Create discussion thread
571async function createDiscussionThread(
572channel: any,
573metaVariants: string[],
622}
623624// Main function - entry point for cron job
625export default async function(remainder: string = "") {
626console.log("🚀 Starting Map Vote Channel Creation");
627const startTime = Date.now();
643};
644645// Load all other required data using getter functions
646const mapData = getHellLetLooseMapData();
647const alphabetImages = getAlphabetImageUrls();
luciaMagicLinkStarterApp.tsx1 match
2import { useState } from "https://esm.sh/react@18.2.0";
34export function App() {
5const [clicked, setClicked] = useState(0);
6return (
9const LOCK_TIMEOUT = 15 * 60 * 1000;
1011// Main function that runs as a scheduled val
12export default async function() {
13console.log("🕒 Map Vote Cron Job started");
14109}
110111// Utility function to clear the lock manually if needed
112export async function clearLock() {
113try {
114await blob.delete("is_creating_map_vote");