Skip to content

Instantly share code, notes, and snippets.

@tyama
Created November 6, 2011 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyama/1342324 to your computer and use it in GitHub Desktop.
Save tyama/1342324 to your computer and use it in GitHub Desktop.
IRCボットテンプレ。(半手動IRCボット: 別チャンネルにて、say:hello。で、発言投げ。)
@Grab(group='org.pircbotx', module='pircbotx', version='1.5')
import org.pircbotx.PircBotX
import org.pircbotx.hooks.ListenerAdapter
def botName = "oreore"
def serverName = "192.168.100.100"
def channel = "#channel"
def channel2 = "#channel2"
def bot = new PircBotX()
bot.name = bot.nick = bot.login = botName
bot.verbose=false
bot.getListenerManager().addListener(
[onMessage:{e ->
println "(${e.user.nick}) ${e.message} [${new Date().format('yyyy/MM/dd HH:mm:ss')}]"
//"say -v Kyoko -r 300 \"${e.message}、と、${e.user.nick}が、言っとる\"".execute()
if(e.message.startsWith('say:')){
def comment = e.message.replace('say:','')
bot.sendMessage(channel, comment)
println "(${botName}) $comment"
}
}] as ListenerAdapter
)
bot.connect serverName
bot.joinChannel channel
bot.joinChannel channel2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment