drunk-meter - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
drunk-meter (478B) | |
--- | |
1 #!/bin/sh | |
2 # | |
3 # Idea from: | |
4 # https://fqcor.com/articles/drunkard/ | |
5 # | |
6 | |
7 export PATH="$HOME/bin:$PATH" | |
8 | |
9 if [ $# -lt 2 ]; | |
10 then | |
11 printf "usage: %s chanpath nick\n" "$(basename "$0")" >&2 | |
12 exit 1 | |
13 fi | |
14 | |
15 chanpath="$1" | |
16 nickname="$2" | |
17 | |
18 if [ ! -e "${chanpath}" ]; | |
19 then | |
20 exit 1 | |
21 fi | |
22 | |
23 grep " <${nickname}> " "${chanpath}" \ | |
24 | tail -n 10 \ | |
25 | { | |
26 while read -r line; | |
27 do | |
28 printf "%s" $(levenshtein-distance "${line}" \ | |
29 "$(autocorrect "${line}")"); | |
30 printf " + "; | |
31 done; | |
32 printf "0\n"; | |
33 } | bc | |
34 |