Add wikipedia replacement trick for one line. - annna - Annna the nice friendly bot. HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/ DIR Log DIR Files DIR Refs DIR Tags DIR README --- DIR commit b86a96228a9b8296adc074af8d8e0401f9499ac0 DIR parent 27fceecf711fb8a4138be9cecf55de0d886c7e1d HTML Author: Annna Robert-Houdin <annna@bitreich.org> Date: Fri, 8 May 2020 20:33:43 +0200 Add wikipedia replacement trick for one line. This part of annna has to be reworked completely. Diffstat: M annna-start-services | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) --- DIR diff --git a/annna-start-services b/annna-start-services @@ -108,6 +108,7 @@ then tmpf=$(mktemp) fetch-url "${uri}" > "${tmpf}" urititle="$(grabtitle < "${tmpf}" | sed 's/^ *\(.\{0,200\}\).*/\1/')" + # TODO: Replace all of this with a better logic for parsing global domains. if [ -n "$urititle" ]; then case "${urititle}" in @@ -128,6 +129,7 @@ then annna-say -c "#bitreich-en" "HTML title: ${urititle}" fi else + wikipedia=0 case "${uri}" in *twitter.com*) nurl="$(printf "%s\n" "${uri}" | sed 's;\(mobile\.\)\{0,1\}twitter\.com;nitter\.net;')" @@ -138,7 +140,10 @@ then *en.wikipedia.org/wiki*) if ! regeximatch "$uri" '\.(jpg,bmp,gif,png,tiff,avi,mp4,webm,mkv,pdf,ps,eps)$'; then nurl="$(printf '%s\n' "${uri}" | sed "s;.*en.wikipedia.org/wiki;gopher://gopherpedia.com/0;")" - annna-say -c '#bitreich-en' "gopherpedia: ${nurl}" + purl="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" + annna-say -c '#bitreich-en' "gopherpedia: ${nurl} ; content: ${purl}" + # Hack, Hack, Hack. + wikipedia=1 fi ;; *) @@ -146,12 +151,15 @@ then ;; esac - purl="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" - if [ -n "${spurl}" ]; + if [ $wikipedia -eq 0 ]; then - annna-say -c "#bitreich-en" "content: ${purl} ; screen: ${spurl} ; HTML title: ${urititle}" - else - annna-say -c "#bitreich-en" "content: ${purl} ; HTML title: ${urititle}" + purl="$(9 htmlfmt < "${tmpf}" | /br/bin/bitreich-paste)" + if [ -n "${spurl}" ]; + then + annna-say -c "#bitreich-en" "content: ${purl} ; screen: ${spurl} ; HTML title: ${urititle}" + else + annna-say -c "#bitreich-en" "content: ${purl} ; HTML title: ${urititle}" + fi fi fi ;;