marvvin

IRC bot
Log | Files | Refs | README | LICENSE

commit eb9854faa41e3a544e9dabb827f4d62cced8348c
parent dd35e39ef5d4a14a62e5e9b405af4ac690a2a675
Author: Hayden Hamilton <hayden@haydenvh.com>
Date:   Fri,  9 Apr 2021 19:28:28 +0100

filters.sh: update

Diffstat:
Mfilters.sh | 203++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 128 insertions(+), 75 deletions(-)

diff --git a/filters.sh b/filters.sh @@ -1,6 +1,17 @@ #!/bin/sh . ./functions.sh +oww(){ + repl_msg $(rand "oww" \ + "bloody hell man" \ + "what is wrong with you‽" \ + "stop it!" \ + "meanie" \ + "I'll tell hhvn about this" \ + "go to hell" \ + ) +} + greet(){ greet=$(sed "s/ $nick.*//;s/^$nick[:,] //") repl_msg "$greet $NICK" @@ -12,16 +23,6 @@ rand(){ echo "$1" } -oww(){ - repl_msg $(rand "oww" \ - "bloody hell man" \ - "what is wrong with you!?" \ - "stop it!" \ - "meanie" \ - "I'll tell hhvn about this" \ - "go to hell" \ - ) -} bin(){ set -- $(cat -) @@ -32,83 +33,135 @@ bin(){ done } -url_title(){ - export in=$(head -n 1) - repl_msg $( - echo hi - url=$(echo "$in" | sed 's/invidio.us/www.youtube.com/g;s/m.imdb.com/www.imdb.com/g' | tr -d '\r' | sed 's~embed/~watch?v=~g') - set -- $url - headers=$($tor curl -qsLD - "$1" | tr -d '\r' | sed '/^[^[:print:]]*$/q' | tr '[:upper:]' '[:lower:]') - echo "$1" | grep 'http[s]*://[w.]*youtu[.]*be' >/dev/null && { - content=$($tor curl -L "$1" | tr -d '\r') - printf "05You05,16Tube ::: " - echo "Title: $(echo "$content" | grep '\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":' | sed 's/.*\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":// ; s/}\]}.*// ; s/\\//g ; s/^\"// ; s/.$//') \ -::: Author: $(echo "$content" | grep -o 'author":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g') \ -::: Upload Date: $(echo "$content" | grep -o 'uploadDate":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g;s/([0-9]*)-([0-9]*)-([0-9]*)/\3-\2-\1/')" - return - } - echo "$1" | grep 'http[s]*://[w.]*imdb.com' >/dev/null && { - content=$($tor curl -L "$1" | tr -d '\r') - printf "88,53 IMDb \nTitle: " - echo "$content" | grep -o '<title[^>]*>[^<]*</title>' | sed 's~.*<title[^>]*>~~g;s~</title>.*~~g' | head -n 1 | sed 's/ - IMDb//g' - printf "Synopsis: " - echo "$content" | grep -io '<meta[^>]*"description[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/' | cut -zc-300 - printf "Run-time: " - echo "$content" | tr '\n' '\t' | grep -o "<time datetime=\"[^>]*>[^<]*" | awk -F">" '{print $2}' | sed 's/[[:space:]]*//;s/[[:space:]]*$//' | head -n 1 | tr -d '\n' - printf " ::: Genres: " - echo "$content" | tr '\n' '\t' | grep -o "\"genre\".*\]," | sed 's/\],.*//g' | tr -d '"\n' | sed 's/genre:[^[:alnum:]]*//' | tr '\t' ' ' | tr -s ' ' - printf " ::: Stars: " - echo "$content" | grep "\"ratingValue\"" | head -n 1 | sed -E 's/.*"([^"]*)"$/\1/g' | tr -d '\n' - printf "/10\n" - return - } - - code=$(echo "$headers" | head -n 1) - ctype=$(echo "$headers" | awk -F":" '$1 == "content-type" {print $2}') - server=$(echo "$headers" | awk -F":" '$1 == "server" {print $2}') - - echo "$ctype" | grep -v 'text/html' >/dev/null && { - echo "$server" | grep -i 'Cloudflare' >/dev/null && send "NOTICE $CHANNEL :Shit: cloudflare." && return - echo "$ctype" | grep '[[:alnum:]]' >/dev/null && out="${out}Content-type:$ctype " - echo "$server" | grep '[[:alnum:]]' >/dev/null && out="${out}Server:$server " - echo "$out" | grep '[[:alnum:]]' >/dev/null && send "$(echo "NOTICE $CHANNEL :$out" | cut -zc-200)" - return - } - content=$($tor curl -L "$1" | tr -d '\r') - title=$(echo "$content" | grep -o '<title[^>]*>[^<]*</title>' | sed 's~.*<title[^>]*>~~g;s~</title>.*~~g' | head -n 1) - published=$(echo "$content" | grep -o '<meta[^>]*"published_time[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/;s/T.*//;s~([0-9]*)-([0-9]*)-([0-9]*)~\3/\2/\1~') - modified=$(echo "$content" | grep -o '<meta[^>]*"modified_time[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/;s/T.*//;s~([0-9]*)-([0-9]*)-([0-9]*)~\3/\2/\1~') - author=$(echo "$content" | grep -o '<meta[^>]*"author[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/') - generator=$(echo "$content" | grep -io '<meta[^>]*"generator[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/') - description=$(echo "$content" | grep -io '<meta[^>]*"description[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/' | cut -zc-200) - - echo "$server" | grep -i 'Cloudflare' >/dev/null && send "NOTICE $CHANNEL :Shit: cloudflare." && return - echo "$title" | grep '[[:alnum:]]' >/dev/null && out="Title: $title " - echo "$published" | grep '[[:alnum:]]' >/dev/null && out="${out}Published: $published " - echo "$modified" | grep '[[:alnum:]]' >/dev/null && out="${out}Last modified: $modified " - echo "$author" | grep '[[:alnum:]]' >/dev/null && out="${out}Author: $author " - echo "$generator" | grep '[[:alnum:]]' >/dev/null && out="${out}Page generator: $generator " - echo "$description" | grep '[[:alnum:]]' >/dev/null && out="${out}Description: $description... " - echo "$ctype" | grep '[[:alnum:]]' >/dev/null && out="${out}Content-type:$ctype " - echo "$server" | grep '[[:alnum:]]' >/dev/null && out="${out}Server:$server " - echo "$out" | grep '[[:alnum:]]' >/dev/null && send "$(echo "NOTICE $CHANNEL :$out" | cut -zc-200)" - ) +binsu(){ + touch /tmp/sudo + set -- $(cat -) + shift 2 + bin/$@ | while IFS= read -r line + do + repl_msg "$line" + done } -url_twitter(){ - echo "Nitter: $(wget -qO- "$(echo "$1" | sed 's~twitter\.com~nitter\.net~g' | awk '{print $1}')" | grep -Po '<title>.*?</title>' | sed 's~^<title>~~g;s~ | nitter</title>$~~g') $(echo "$(echo "$1" | awk '{print $1}')" | sed 's~twitter\.com~nitter\.net~g')" -} +# url_title(){ +# export in=$(head -n 1) +# repl_msg $( +# echo hi +# url=$(echo "$in" | sed 's/invidio.us/www.youtube.com/g;s/m.imdb.com/www.imdb.com/g' | tr -d '\r' | sed 's~embed/~watch?v=~g') +# set -- $url +# headers=$($tor curl -qsLD - "$1" | tr -d '\r' | sed '/^[^[:print:]]*$/q' | tr '[:upper:]' '[:lower:]') +# echo "$1" | grep 'http[s]*://[w.]*youtu[.]*be' >/dev/null && { +# content=$($tor curl -L "$1" | tr -d '\r') +# printf "05You05,16Tube ::: " +# echo "Title: $(echo "$content" | grep '\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":' | sed 's/.*\[{\"videoPrimaryInfoRenderer\":{\"title\":{\"runs\"\:\[{\"text\":// ; s/}\]}.*// ; s/\\//g ; s/^\"// ; s/.$//') \ +# ::: Author: $(echo "$content" | grep -o 'author":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g') \ +# ::: Upload Date: $(echo "$content" | grep -o 'uploadDate":[^}]*}' | sed -E 's/.*:"([^"]*).*/\1/g;s/([0-9]*)-([0-9]*)-([0-9]*)/\3-\2-\1/')" +# return +# } +# echo "$1" | grep 'http[s]*://[w.]*imdb.com' >/dev/null && { +# content=$($tor curl -L "$1" | tr -d '\r') +# printf "88,53 IMDb \nTitle: " +# echo "$content" | grep -o '<title[^>]*>[^<]*</title>' | sed 's~.*<title[^>]*>~~g;s~</title>.*~~g' | head -n 1 | sed 's/ - IMDb//g' +# printf "Synopsis: " +# echo "$content" | grep -io '<meta[^>]*"description[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/' | cut -zc-300 +# printf "Run-time: " +# echo "$content" | tr '\n' '\t' | grep -o "<time datetime=\"[^>]*>[^<]*" | awk -F">" '{print $2}' | sed 's/[[:space:]]*//;s/[[:space:]]*$//' | head -n 1 | tr -d '\n' +# printf " ::: Genres: " +# echo "$content" | tr '\n' '\t' | grep -o "\"genre\".*\]," | sed 's/\],.*//g' | tr -d '"\n' | sed 's/genre:[^[:alnum:]]*//' | tr '\t' ' ' | tr -s ' ' +# printf " ::: Stars: " +# echo "$content" | grep "\"ratingValue\"" | head -n 1 | sed -E 's/.*"([^"]*)"$/\1/g' | tr -d '\n' +# printf "/10\n" +# return +# } + +# code=$(echo "$headers" | head -n 1) +# ctype=$(echo "$headers" | awk -F":" '$1 == "content-type" {print $2}') +# server=$(echo "$headers" | awk -F":" '$1 == "server" {print $2}') + +# echo "$ctype" | grep -v 'text/html' >/dev/null && { +# echo "$server" | grep -i 'Cloudflare' >/dev/null && send "NOTICE $CHANNEL :Shit: cloudflare." && return +# echo "$ctype" | grep '[[:alnum:]]' >/dev/null && out="${out}Content-type:$ctype " +# echo "$server" | grep '[[:alnum:]]' >/dev/null && out="${out}Server:$server " +# echo "$out" | grep '[[:alnum:]]' >/dev/null && send "$(echo "NOTICE $CHANNEL :$out" | cut -zc-200)" +# return +# } +# content=$($tor curl -L "$1" | tr -d '\r') +# title=$(echo "$content" | grep -o '<title[^>]*>[^<]*</title>' | sed 's~.*<title[^>]*>~~g;s~</title>.*~~g' | head -n 1) +# published=$(echo "$content" | grep -o '<meta[^>]*"published_time[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/;s/T.*//;s~([0-9]*)-([0-9]*)-([0-9]*)~\3/\2/\1~') +# modified=$(echo "$content" | grep -o '<meta[^>]*"modified_time[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/;s/T.*//;s~([0-9]*)-([0-9]*)-([0-9]*)~\3/\2/\1~') +# author=$(echo "$content" | grep -o '<meta[^>]*"author[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/') +# generator=$(echo "$content" | grep -io '<meta[^>]*"generator[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/') +# description=$(echo "$content" | grep -io '<meta[^>]*"description[^>]*>' | sed -E 's/.*content="([^"]*)".*/\1/' | cut -zc-200) + +# echo "$server" | grep -i 'Cloudflare' >/dev/null && send "NOTICE $CHANNEL :Shit: cloudflare." && return +# echo "$title" | grep '[[:alnum:]]' >/dev/null && out="Title: $title " +# echo "$published" | grep '[[:alnum:]]' >/dev/null && out="${out}Published: $published " +# echo "$modified" | grep '[[:alnum:]]' >/dev/null && out="${out}Last modified: $modified " +# echo "$author" | grep '[[:alnum:]]' >/dev/null && out="${out}Author: $author " +# echo "$generator" | grep '[[:alnum:]]' >/dev/null && out="${out}Page generator: $generator " +# echo "$description" | grep '[[:alnum:]]' >/dev/null && out="${out}Description: $description... " +# echo "$ctype" | grep '[[:alnum:]]' >/dev/null && out="${out}Content-type:$ctype " +# echo "$server" | grep '[[:alnum:]]' >/dev/null && out="${out}Server:$server " +# echo "$out" | grep '[[:alnum:]]' >/dev/null && send "$(echo "NOTICE $CHANNEL :$out" | cut -zc-200)" +# ) +# } puma(){ repl_msg "Aha, beware the puma, $NAME" } +weed(){ + repl_action $(rand \ + "puffs" \ + "inhales" \ + "is high as a kite" \ + ) +} + +job(){ + repl_msg $(rand \ + "How much are we talking?" \ + "$NICK, robots do not require much maintainance" \ + ) +} + +food(){ + repl_action $(rand \ + "scoffs it down" \ + "shoves it in his mouth" \ + "noms" \ + ) +} + +huh(){ + repl_msg $(rand \ + "$NICK, huh?" \ + "I don't get it" \ + "That makes no sense" \ + "Try something else.." \ + ) +} + +stupid(){ + repl_msg $(rand \ + "s s sorry" \ + "I know.. :(" \ + "it was an accident! :|" \ + ) +} + match_motd send_join "#hlircnet" match_motd send_join "#test" match_msg "^($nick: |$nick, |)(good |)(hi|hello|greetings|sup|morning|afternoon|evening|day)(.*$nick.*|)$" greet +match_msg "(dumb|stupid|retard|useless|pointless).*(bot|$nick)" stupid +match_action "(slaps|smacks|whacks|hits|strikes|punches|shoots|stabs|wounds) $nick" oww +match_action "(gives|passes|hands).*(blunt|bong|joint)" weed +match_action "(gives|passes|hands).*job" job +match_action "(gives|passes|hands).*(food|cookie|biscuit|leftovers|dinner|scraps)" food match_msg "^($nick: |$nick, |)(good |)night(.*$nick.*|)$" night -match_action "^(hits|strikes|punches|shoots|stabs|wounds) $nick" oww match_msg "$nick[,:] ($(ls bin/ | tr '\n' '|' | sed 's/|$//g'))" bin +match_msg "$nick[,:] (sudo|doas) ($(ls bin/ | tr '\n' '|' | sed 's/|$//g'))" binsu match_msg "http[s]*://.*" url_title match_msg "puma" puma match_msg "^(lul|lol|hah|hehe|heh|haha).*wut\?" repl_action "shrugs" +match_msg "^marvvin[:,].*" huh