Advertisement
mkv

IRC Hilight Backlog

mkv
Jul 31st, 2014
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.14 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # IRC Hilight Backlog by ed <irc.rizon.net>
  4. # BSD licensed -- 2014-07-31 -- v1.0
  5. #
  6. # Must be run with the same user as ZNC.
  7. # First argument (int) is day selector:
  8. #   0: Hilights from today (default),
  9. #   1: Hilights from one day ago...
  10. #
  11. # Line  17:     Replace /ed/ with /your-username/
  12. # Lines 38-41:  Modify to fit your needs
  13. #
  14.  
  15. [ "x$1" == "x" ] && d=0 || d=$1
  16. dt=$(date +%Y%m%d --date="-$d day")
  17. cd ~/.znc/users/ed/moddata/log
  18. (
  19.     ls -1 |
  20.     grep "_$dt.log" |
  21.     grep -v "#" |
  22.     while read x
  23.     do
  24.         n=$(
  25.             cat "$x" |
  26.             grep -E "^...:..:... <ed> " -B1000 |
  27.             wc -l
  28.         )
  29.         nn=$(
  30.             cat "$x" |
  31.             wc -l
  32.         )
  33.         n=$((nn-n))
  34.         cat "$x" | tail -n $n
  35.     done
  36.  
  37. grep -P \
  38. "[Ll][Oo][Oo][Pp].?[Ss][Tt][Rr][Ee][Aa][Mm]|"\
  39. "[Tt][Rr][Ii][Pp][Ff][Ll][Aa][Gg]|"\
  40. "[^a-zA-Z0-9%<\x27]([Ee][Dd])([^a-zA-Z0-9%>]|$)|"\
  41. "[^a-zA-Z0-9][oO][cC][vV]([^a-zA-Z0-9]|$)" \
  42. --color=always *_$dt.log |
  43. grep -vE "] \*\*\* ..i.s:"
  44.  
  45. ) |
  46. tee hil.tmp |
  47. (
  48.     cat
  49.     cat hil.$dt
  50. ) |
  51. sort |
  52. uniq -u |
  53. less -R
  54.  
  55. read -n 1 -r -p "Hide these messages next time? [y/N]: "
  56. if [[ $REPLY =~ ^[Yy] ]]
  57. then
  58.     cp hil.tmp hil.$dt
  59. else
  60.     rm hil.tmp
  61. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement