Skip to main content
Glama
pattern_builder.shβ€’3.34 kB
#!/bin/bash # Script to build attribution patterns dynamically # Get the script's directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # Configuration file paths PATTERNS_CONFIG="${SCRIPT_DIR}/config/attribution_patterns.conf" # Temporary storage for pattern parts PREFIXES=() NAMES=() DOMAINS=() SYMBOLS=() # Function to read and parse the configuration file parse_config() { # Check if config file exists if [ ! -f "$PATTERNS_CONFIG" ]; then echo "Error: Configuration file not found at $PATTERNS_CONFIG" exit 1 fi # Read configuration file line by line while IFS= read -r line || [ -n "$line" ]; do # Skip comments and empty lines if [[ "$line" =~ ^#.*$ ]] || [[ -z "${line// }" ]]; then continue fi # Categorize pattern parts based on their characteristics if [[ "$line" == *"_by_"* ]] || [[ "$line" == *"_with_"* ]]; then PREFIXES+=("$line") elif [[ "$line" == *"@"* ]]; then DOMAINS+=("$line") elif [[ "$line" == *"a_"* ]] || [[ "$line" == *"c_"* ]]; then NAMES+=("$line") else SYMBOLS+=("$line") fi done < "$PATTERNS_CONFIG" } # Function to build attribution patterns build_patterns() { # Clear any existing patterns patterns=() # Build patterns from parts for prefix in "${PREFIXES[@]}"; do for name in "${NAMES[@]}"; do # Convert underscore-separated letters to regular letters processed_name=$(echo "$name" | sed 's/a_/a/g; s/c_/c/g; s/i_/i/g; s/s_/s/g; s/t_/t/g; s/n_/n/g; s/h_/h/g; s/r_/r/g; s/o_/o/g; s/p_/p/g; s/l_/l/g; s/u_/u/g; s/d_/d/g; s/e_/e/g') # Create pattern combinations pattern="${prefix}${processed_name}" pattern=$(echo "$pattern" | sed 's/gen_with_/Generated with /g; s/gen_by_/Generated by /g; s/created_with_/Created with /g; s/created_by_/Created by /g; s/authored_by_/Authored by /g; s/co_authored_by_/Co-Authored-By: /g') patterns+=("$pattern") # Add variations with symbols for symbol in "${SYMBOLS[@]}"; do if [[ "$symbol" == "\[" && "$prefix" == "gen_with_" ]]; then pattern=$(echo "${prefix}${processed_name}" | sed 's/gen_with_/Generated with \[/g') pattern="${pattern}\]" patterns+=("$pattern") fi done done done # Add domain-specific patterns for name in "${NAMES[@]}"; do processed_name=$(echo "$name" | sed 's/a_/a/g; s/c_/c/g; s/i_/i/g; s/s_/s/g; s/t_/t/g; s/n_/n/g; s/h_/h/g; s/r_/r/g; s/o_/o/g; s/p_/p/g; s/l_/l/g; s/u_/u/g; s/d_/d/g; s/e_/e/g') for domain in "${DOMAINS[@]}"; do if [[ "$domain" == "noreply@" && "$name" == "a_n_t_h_r_o_p_i_c" ]]; then pattern="${domain}${processed_name}.com" patterns+=("$pattern") fi done done # Add emoji variations for prefix in "${PREFIXES[@]}"; do if [[ "$prefix" == "gen_"* ]]; then for symbol in "${SYMBOLS[@]}"; do if [[ "$symbol" == "πŸ€–" ]]; then pattern="${symbol} $(echo "$prefix" | sed 's/gen_with_/Generated with /g; s/gen_by_/Generated by /g')" patterns+=("$pattern") fi done fi done # Add "AI-generated" pattern patterns+=("AI-generated") # Return the patterns array echo "${patterns[@]}" } # Main execution parse_config patterns=$(build_patterns) echo "$patterns"

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kesslerio/attio-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server