# irc -- IRC aliases and functions for catgirl + general IRC tools # ============================================================================ # CATGIRL # ============================================================================ alias cg='catgirl' alias cglibera='catgirl libera' alias cgoftc='catgirl oftc' alias cgtilde='catgirl tilde' alias cglog='ls ~/.local/share/catgirl/log/' # ============================================================================ # SIC (SUCKLESS IRC CLIENT -- MINIMAL) # ============================================================================ alias siclibera='sic -h irc.libera.chat -p 6697' alias sicoftc='sic -h irc.oftc.net -p 6697' # ============================================================================ # IRSSI # ============================================================================ alias irssi='irssi --config=~/.config/irssi/config --home=~/.config/irssi' alias irssitm='tmux new-session -d -s irc irssi && tmux attach -t irc' # ============================================================================ # WEECHAT # ============================================================================ alias wctm='tmux new-session -d -s weechat weechat && tmux attach -t weechat' alias wclog='ls ~/.local/share/weechat/logs/' # ============================================================================ # ZNC (BOUNCER) # ============================================================================ alias zncstatus='systemctl --user status znc 2>/dev/null || systemctl status znc' alias zncstart='systemctl --user start znc 2>/dev/null || systemctl start znc' alias zncrestart='systemctl --user restart znc 2>/dev/null || systemctl restart znc' alias znclog='tail -f ~/.znc/moddata/log/' alias zncweb='echo "ZNC web: https://localhost:6697"' # ============================================================================ # LOG SEARCHING # ============================================================================ alias ircgrep='grep -rn --include="*.log" --include="*.weechatlog"' alias irctoday='grep "$(date +%Y-%m-%d)"' alias irclinks='grep -ohE "https?://[^ ]+"' # ============================================================================ # NETWORK SHORTCUTS # ============================================================================ alias libera='echo "irc.libera.chat:6697 (TLS)"' alias oftc='echo "irc.oftc.net:6697 (TLS)"' alias efnet='echo "irc.efnet.org:6697 (TLS)"' alias undernet='echo "irc.undernet.org:6697 (TLS)"' alias ircnet='echo "irc.ircnet.net:6697 (TLS)"' alias tilde='echo "irc.tilde.chat:6697 (TLS)"' alias sucklessirc='echo "irc.oftc.net:6697 #suckless (TLS)"' alias plan9irc='echo "irc.libera.chat:6697 #cat-v #plan9 (TLS)"' # ============================================================================ # IRC OVER TOR # ============================================================================ alias torirc='torsocks catgirl' # ============================================================================ # CATGIRL HELPERS # ============================================================================ # search catgirl logs for a term cggrep() { term="$1"; channel="${2:-}" [ -z "$term" ] && { echo "Usage: cggrep [channel]"; return 1; } logdir="$HOME/.local/share/catgirl/log" if [ -n "$channel" ]; then grep -rn "$term" "$logdir"/*"$channel"* 2>/dev/null else grep -rn "$term" "$logdir" 2>/dev/null fi } # show recent activity across all catgirl logs cgrecent() { count="${1:-20}" logdir="$HOME/.local/share/catgirl/log" find "$logdir" -name "*.log" -newer "$logdir" -exec tail -1 {} + 2>/dev/null | sort | tail -"$count" } # ============================================================================ # WEECHAT HELPERS # ============================================================================ # search weechat logs wcgrep() { term="$1"; channel="${2:-}" [ -z "$term" ] && { echo "Usage: wcgrep [channel]"; return 1; } logdir="$HOME/.local/share/weechat/logs" if [ -n "$channel" ]; then grep -rn "$term" "$logdir"/*"$channel"* 2>/dev/null else grep -rn "$term" "$logdir" 2>/dev/null fi } # ============================================================================ # ZNC BOUNCER MANAGEMENT # ============================================================================ # add a new network to ZNC zncaddnet() { network="$1"; server="$2"; port="${3:-6697}" [ -z "$server" ] && { echo "Usage: zncaddnet [port]"; return 1; } echo "[*] Add to ZNC webpanel or use:" echo " /znc AddNetwork $network" echo " /znc AddServer $network $server +$port" echo " /znc AddChan $network #channel" } # ============================================================================ # GENERAL IRC UTILITIES # ============================================================================ # extract all URLs from IRC logs ircurls() { file="$1" [ -z "$file" ] && { echo "Usage: ircurls "; return 1; } grep -ohE 'https?://[^ ]+' "$file" | sort -u } # count messages per nick in a log ircstats() { file="$1" [ -z "$file" ] && { echo "Usage: ircstats "; return 1; } grep -oE '<[^>]+>' "$file" | sort | uniq -c | sort -rn | head -20 } # generate an IRC log summary ircsummary() { file="$1" [ -z "$file" ] && { echo "Usage: ircsummary "; return 1; } total=$(wc -l < "$file") nicks=$(grep -oE '<[^>]+>' "$file" | sort -u | wc -l) urls=$(grep -ohE 'https?://[^ ]+' "$file" | wc -l) echo "Lines: $total" echo "Nicks: $nicks" echo "URLs: $urls" echo "" echo "Top talkers:" grep -oE '<[^>]+>' "$file" | sort | uniq -c | sort -rn | head -5 } # quick connect function (picks the right client) ircconnect() { network="$1" [ -z "$network" ] && { echo "Usage: ircconnect "; return 1; } case "$network" in libera) server="irc.libera.chat"; port=6697 ;; oftc) server="irc.oftc.net"; port=6697 ;; tilde) server="irc.tilde.chat"; port=6697 ;; efnet) server="irc.efnet.org"; port=6697 ;; *) echo "Unknown network: $network"; return 1 ;; esac if command -v catgirl >/dev/null; then catgirl -h "$server" -p "$port" elif command -v irssi >/dev/null; then irssi -c "$server" -p "$port" else echo "No IRC client found" return 1 fi } # notify on mention (for use in a pipeline: tail -f log | ircnotify nick) ircnotify() { nick="$1" [ -z "$nick" ] && { echo "Usage: tail -f | ircnotify "; return 1; } while IFS= read -r line; do if echo "$line" | grep -qi "$nick"; then notify-send "IRC Mention" "$line" 2>/dev/null printf '\007' # bell fi done }