Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Forked from kiy0taka/commit-irc.groovy
Created September 9, 2010 04:40
Show Gist options
  • Save kiy0taka/571383 to your computer and use it in GitHub Desktop.
Save kiy0taka/571383 to your computer and use it in GitHub Desktop.
Using Groovy to Git post-commit hook: IRC Bot to print commit Message
@Grab('pircbot:pircbot:1.4.2')
import org.jibble.pircbot.*;
def (host, port, channel) = ['<Server>', <Port>, '<Channel>']
def bot = [:] as PircBot
bot.name = 'groovy_bot'
bot.encoding = 'ISO-2022-JP'
bot.connect host, port
bot.joinChannel channel
bot.sendRawLine(args*.split('\n').flatten().collect{"PRIVMSG $channel :$it"}.join('\n'))
bot.disconnect()
System.exit 0
#!/bin/bash
export LANG=ja_JP.UTF-8
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk/
export GROOVY_HOME=/usr/local/groovy
export PATH=$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH
LOG=`git log -1`
groovy /path/to/git-repo/hooks/commit-irc.groovy "$LOG" >> /tmp/post-commit.log 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment