til-user - annna - Annna the nice friendly bot. | |
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6… | |
Log | |
Files | |
Refs | |
Tags | |
README | |
--- | |
til-user (600B) | |
--- | |
1 #!/bin/sh | |
2 | |
3 nick="${1}" | |
4 tilmodbase="$HOME/bin/modules/til" | |
5 tildb="${tilmodbase}/til.txt" | |
6 | |
7 # Make sure there's a file to parse. | |
8 if [ ! -f "${tildb}" ]; | |
9 then | |
10 exit 1 | |
11 fi | |
12 | |
13 format_user_tils() { | |
14 awk -v nick="${nick}" \ | |
15 'BEGIN { | |
16 FS="\t" | |
17 print nick "\n" | |
18 } | |
19 $1 ~ nick { | |
20 print $3 | |
21 print "\nTIL" $2 "\n\n" | |
22 }' "${tildb}" | |
23 } | |
24 | |
25 if user_learned_count="$(grep -cP "^${nick}\t" "${tildb}")"; | |
26 then | |
27 results=$(format_user_tils "${nick}" \ | |
28 | fmt -w 69 \ | |
29 | /br/bin/bitreich-paste) | |
30 printf "here is all your learning: %s" "${results}" | |
31 exit 0 | |
32 else | |
33 printf "you haven't learned anything yet :o" | |
34 exit 0 | |
35 fi |