Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 184 lines (145 sloc) 4.674 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
#!/usr/bin/awk -f
# Extract IRC statistics from Weechat logs for various things.
#
# Usage (include one of the following parameters):
# blamereport showkicks=true showblames=true penovwhiteinge=true \
# showchatty=true showjoinsparts=true showemotes=true

{
    IGNORECASE = 1

    if (NR == 1) {
        begindate = $1
    }
}

$0 ~ /hobo knife/ {
    knife += 1
}

# Collect chatty stats
$3 ~ /[a-zA-Z@+_-]+/ {
    sub(/@/, "", $3)
    sub(/+/, "", $3)
    chatty[$3] += 1
}

# Collect joins
$6 == "has" && $7 == "joined" {
    joins_parts[$4] += 1
    joins[$4] = $1
}

# Collect parts
$6 == "has" && $7 == "quit" {
    joins_parts[$4] += 1
    quits[$4] = $1
}

# Collect peno vs. whiteinge stats
$3 == "*" && $4 == "peno" && $6 ~ /wh[i1]t[e3][i1]ng[e3]/ {
    action=$4 " " $5 " whiteinge"

    for (i=7; i<=NF; i++) {
        action = action " " $i
    }

    penoactions[action] += 1
}

# Collect blame stats
$3 == "*" && $5 == "blames" {
    blames += 1
    blamers[$4] += 1
    blamees[$6] += 1
}

# Collect emote stats
$3 == "*" {
    emotes[$4] += 1
}

# Collect kick stats
$3 == "<--" && $6 == "kicked" {
    kicks += 1
    kickers[$4] += 1
    kickees[$7] += 1

    reason = ""
    for (i=8; i<=NF; i++) {
        reason = reason " " $i
    }
    kick_reasons[reason] += 1
}

END {
    ### blames
    if (showblames == "true") {
        for (i in blamers) num_blamers++
        for (i in blamees) num_blamees++

        print "\nThere has been", blames, "aspersions cast",
            "about", num_blamees, "innocent souls",
            "by", num_blamers, "vicious haters",
            "since", begindate "."

        print "\nTop 5 blamers:"

        command = "sort -r -n -k4 | head -5"

        for (person in blamers) print "\t" person, "cast blame", blamers[person],
            "times" | command
        close(command)

        print "\nTop 5 blamees:"

        for (person in blamees) print "\t" person, "was blamed", blamees[person],
            "times" | command
        close(command)
    }

    ### kicks
    if (showkicks == "true") {
        for (i in kickers) num_kickers++
        for (i in kickees) num_kickees++

        print "\nThere has been", kicks, "forceful explusions from our fair channel",
            "of", num_kickees, "innocent victims",
            "by", num_kickers, "wrathful bullies",
            "since", begindate "."

        print "\nTop 5 kickers:"

        command = "sort -r -n -k4 | head -5"

        for (person in kickers) print "\t" person, "has kicked", kickers[person],
            "times" | command
        close(command)

        print "\nTop 5 kickees:"

        for (person in kickees) print "\t" person, "was kicked", kickees[person],
            "times" | command
        close(command)

        if (showkickreasons == "true") {
            print "\nReasons for kicking:"
            for (reason in kick_reasons) print "\t" reason
        }
    }

    ### penoactions
    if (penovwhiteinge == "true") {
        print "\npeno has done the following horrible things to whiteinge:"

        penocommand = "sort -r -n -k4"

        for (action in penoactions) print "\t" action, penoactions[action],
            "times" | penocommand
        close(penocommand)
    }

    ### chattyness
    if (showchatty == "true") {
        print "\nThe five most talkative people since", begindate, "are:\n"

        chattycommand = "sort -r -n -k4 | head -5"
        for (person in chatty) print "\t" person, "spoke up", chatty[person],
             "times" | chattycommand
        close(chattycommand)
    }

    ### joins/parts
    if (showjoinsparts == "true") {
        print "\nThe five people who have joined/parted most often since",
              begindate, "are:\n"

        joinpartcommand = "sort -r -n -k3 | head -5"
        for (person in joins_parts) print "\t" person, "joined/parted",
             joins_parts[person], "times" | joinpartcommand
        close(joinpartcommand)
    }

    ### emotes
    if (showemotes == "true") {
        print "\nThe five people who have emoted most often since",
              begindate, "are:\n"

        emotecommand = "sort -r -n -k3 | head -5"
        for (person in emotes) print "\t" person, "emoted",
             emotes[person], "times" | emotecommand
        close(emotecommand)
    }

    ### hobo knife
    if (showknife == "true") {
        print "\nThere have been", knife, "hobo-knife wielding individuals since",
              begindate, "\n"

        # emotecommand = "sort -r -n -k3 | head -5"
        # for (person in emotes) print "\t" person, "emoted",
        # emotes[person], "times" | emotecommand
        # close(emotecommand)
    }
}
Something went wrong with that request. Please try again.