Introduction
Introduction Statistics Contact Development Disclaimer Help
shame - annna - Annna the nice friendly bot.
git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws6…
Log
Files
Refs
Tags
README
---
shame (754B)
---
1 #!/bin/sh
2
3 shamemodbase="$HOME/bin/modules/shame"
4 shamedb="${shamemodbase}/shame.txt"
5
6 function getshameval {
7 shameval="$(grep "^$1" "${shamedb}" | cut -f 2)"
8 [ -z "${shameval}" ] && printf "0\n"
9 printf "%s\n" "${shameval}"
10 }
11
12 function setshameval {
13 if [ -n "$(grep "^${1}" "${shamedb}")" ];
14 then
15 sed -i "s,${1}\t.*,${1}\t${2}," "${shamedb}"
16 else
17 printf "%s\t%d\n" "${1}" "${2}" >> "${shamedb}"
18 fi
19 }
20
21 function modifyshame {
22 shametag="$1"
23 shameval=$(getshameval "${shametag}")
24 newshameval="$(printf "%d%s\n" "${shameval}" "$2" | bc)"
25 setshameval "${shametag}" $newshameval
26 }
27
28 function incshame {
29 modifyshame "$1" " + 1"
30 }
31
32 shamestr="$1"
33 if [ -n "${shamestr}" ];
34 then
35 incshame "${shamestr}"
36 else
37 sort -r -k 2 "${shamedb}" | column -t
38 fi
39
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.