hn-remote-ts-genai-jobscommentParser.ts11 matches
1/**
2* Comment Parser
3* Functions to parse Hacker News comments and filter for job listings
4*/
522* @param text The comment text to check
23*/
24export function hasTypeScriptAndGenAI(text: string): boolean {
25const lowerText = text.toLowerCase();
26
56* @param text The comment text to check
57*/
58export function isRemoteJob(text: string): boolean {
59const lowerText = text.toLowerCase();
60
84* @param text The comment text
85*/
86export function extractCompany(text: string): string {
87const companyMatch = text.match(/^([^|]*?)(?=\s*\||\n|$)/);
88if (companyMatch && companyMatch[1].trim()) {
111* @param text The comment text
112*/
113export function extractPosition(text: string): string {
114// Common patterns for job titles in HN threads
115const positionPatterns = [
135* @param text The comment text
136*/
137export function extractSkills(text: string): string[] {
138const lowerText = text.toLowerCase();
139const skills: string[] = [];
174* @param text The comment text
175*/
176export function extractLocation(text: string): string {
177if (isRemoteJob(text)) {
178// Check for remote with specific regions
216* @param text The comment text
217*/
218export function extractUrl(text: string): string | undefined {
219// Look for URLs in the text
220const urlMatch = text.match(/(https?:\/\/[^\s]+)/);
226* @param text The comment text
227*/
228export function extractDescription(text: string): string {
229// Remove HTML tags for clean text
230const cleanText = text.replace(/<[^>]*>/g, ' ').replace(/\s+/g, ' ').trim();
257* @returns A parsed job listing or null if not a valid job listing
258*/
259export function parseJobListing(comment: HNItem): JobListing | null {
260if (!comment.text) {
261return null;
288* @returns Array of parsed job listings
289*/
290export function filterJobListings(comments: HNItem[]): JobListing[] {
291const jobListings: JobListing[] = [];
292
1/**
2* Hacker News API helper functions
3* Provides utilities to interact with the official Hacker News API
4*/
28* @returns The item data or null if not found
29*/
30export async function fetchItem(id: number): Promise<HNItem | null> {
31try {
32const response = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`);
46* @returns An array of comment items
47*/
48export async function fetchComments(storyId: number): Promise<HNItem[]> {
49const story = await fetchItem(storyId);
50if (!story || !story.kids || story.kids.length === 0) {
69* @returns The thread ID or null if not found
70*/
71export async function findLatestWhoIsHiringThread(): Promise<number | null> {
72try {
73// First get the user information for "whoishiring" account
105* This is useful because the thread is typically posted on the first of each month
106*/
107export function getFallbackThreadId(): number {
108// May 2023 "Who is hiring?" thread ID as a fallback
109// In a real implementation, you might want to update this periodically
hn-remote-ts-genai-jobsREADME.md2 matches
1718- `backend/index.ts` - Main script that orchestrates the entire process
19- `backend/hackerNewsApi.ts` - Functions to interact with the Hacker News API
20- `backend/commentParser.ts` - Functions to parse and filter job listings
2122## View Results
slacktransform.tsx16 matches
1import { DefineFunction, Schema, SlackFunction, type SlackFunctionArgs } from "deno-slack-sdk/mod.ts";
2import SampleObjectDatastore from "./datastore.ts";
34/**
5* Functions are reusable building blocks of automation that accept
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({
11callback_id: "sample_function",
12title: "Sample function",
13description: "A sample function",
14source_file: "functions/sample_function.ts",
15input_parameters: {
16properties: {
3839/**
40* SlackFunction takes in two arguments: the CustomFunction
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(
46SampleFunctionDefinition,
47async ({ inputs, client }: SlackFunctionArgs) => {
48const uuid = crypto.randomUUID();
49
4import { getCurrentConfig } from "https://www.val.town/x/ktodaz/Discord_Bot_Services/code/map_vote/map-vote-getCurrentConfig.tsx";
56// Main configuration function
7export async function setupMapVoteSystem() {
8console.log("🔧 Setting up Map Vote Channel Creator System");
917return {
18success: true,
19message: "Setup completed successfully. You can now use the map-vote-channel-creator function.",
20};
21} catch (error) {
2930// Initialize SQLite database for vote tallying
31async function initializeDatabase() {
32console.log("🔧 Setting up SQLite database...");
337172// Check if environment variables exist and suggest default values
73async function initializeEnvironmentVariables() {
74console.log("🔧 Checking environment variables...");
75132133// Update Discord configuration
134export async function updateDiscordConfig(config: {
135guildId?: string;
136categoryId?: string;
179180// Update voting requirements
181export async function updateVotingRequirements(config: {
182maxVotesPerVoter?: number;
183numberOfWinners?: number;
215216// Update map variant options
217export async function updateMapVariantOptions(options: {
218enableDawn?: boolean;
219enableDay?: boolean;
286287// Get a single map for testing/development purposes
288export function getTestMapData() {
289return {
290Maps: [
311312// Run a test creation of a channel - this would be a dry run without actually creating the channel
313export async function testChannelSetup() {
314try {
315// Validate Discord settings by checking environment variables
telegramBotStarterbotFunctions.js19 matches
1// ============================================================
2// CORE FUNCTIONALITY
3// ============================================================
4import storage from "./storage.js";
7* Expose this as an HTTP endpoint in Val.town
8*/
9async function handleTelegramWebhook(req) {
10try {
11const update = await req.json();
50* Process commands from the owner
51*/
52async function processOwnerCommand(message) {
53const text = message.text || "";
54175* Get information about a user
176*/
177async function getUserInfo(userId) {
178return await storage.get(`userInfo:${userId}`);
179}
182* Get list of all active users who have messaged the bot
183*/
184async function getActiveUsers() {
185// Fetch raw user data from the blob storage
186const rawUserKeys = await storage.list({ prefix: "userInfo:" });
210* Get list of blocked user IDs
211*/
212async function getBlockedUsers() {
213return await storage.get("blockedUsers") || [];
214}
217* Block a user
218*/
219async function blockUser(userId) {
220const blockedUsers = await getBlockedUsers();
221userId = userId.toString();
232* Unblock a user
233*/
234async function unblockUser(userId) {
235const blockedUsers = await getBlockedUsers();
236userId = userId.toString();
252* Store a message in the database
253*/
254async function storeMessage(userId, userName, text, direction) {
255const messages = await getMessages(userId) || [];
256279* Get message history for a specific user
280*/
281async function getMessages(userId) {
282return await storage.get(`messages:${userId}`) || [];
283}
286* Notify the owner about new incoming messages
287*/
288async function notifyOwner(userId, userName, messageText) {
289const ownerChatId = process.env.OWNER_CHAT_ID;
290299* Reply to a specific user
300*/
301async function replyToUser(userId, text) {
302// Send the message to the user
303const success = await sendTelegramMessage(userId, text);
333* Send a message using the Telegram API
334*/
335async function sendTelegramMessage(chatId, text) {
336try {
337const botToken = process.env.TELEGRAM_BOT_TOKEN;
356357// ============================================================
358// SETUP FUNCTIONS
359// ============================================================
360363* Use this once during initial setup
364*/
365async function setupWebhook(webhookUrl) {
366try {
367const botToken = process.env.TELEGRAM_BOT_TOKEN;
387* Get information about the webhook status
388*/
389async function getWebhookInfo() {
390try {
391const botToken = process.env.TELEGRAM_BOT_TOKEN;
403* Send a welcome message to yourself to verify the bot is working
404*/
405async function testBot() {
406const ownerChatId = process.env.OWNER_CHAT_ID;
407424}
425426// Export the functions
427export default {
428// Main webhook handler
429telegram: handleTelegramWebhook,
430431// Setup and utility functions
432setupWebhook,
433getWebhookInfo,
nameSeeingServermain.tsx3 matches
5let mostRecentName: string | null = null;
67function handleGet(req: ExpressRequest, res: ExpressResponse) {
8res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
1011const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13const body = zPostBody.safeParse(req.body);
14if (!body.success) {
52send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55let resStatus = 200;
56
nameSeeingServerjmain.tsx3 matches
5let mostRecentName: string | null = null;
67function handleGet(req: ExpressRequest, res: ExpressResponse) {
8res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
1011const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13const body = zPostBody.safeParse(req.body);
14if (!body.success) {
52send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55let resStatus = 200;
56
nameSeeingServermain.tsx3 matches
5let mostRecentName: string | null = null;
67function handleGet(req: ExpressRequest, res: ExpressResponse) {
8res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
1011const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13const body = zPostBody.safeParse(req.body);
14if (!body.success) {
52send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55let resStatus = 200;
56
nameSeeingServermain.tsx3 matches
5let mostRecentName: string | null = null;
67function handleGet(req: ExpressRequest, res: ExpressResponse) {
8res.send({ namesPreviouslySeen: namesPreviouslySeen.size, mostRecentName });
9}
1011const zPostBody = z.any();
12function handlePost(req: ExpressRequest, res: ExpressResponse) {
13const body = zPostBody.safeParse(req.body);
14if (!body.success) {
52send: (json: any) => void;
53}
54export default async function(req: Request): Promise<Response> {
55let resStatus = 200;
56