Skip to content

Instantly share code, notes, and snippets.

@maxdavid
Created March 20, 2014 23:21
Show Gist options
  • Save maxdavid/9676174 to your computer and use it in GitHub Desktop.
Save maxdavid/9676174 to your computer and use it in GitHub Desktop.
IRC bot that plays 'TESC Plays Nethack', a crowdsourced nethack game that takes commands from an IRC channel. 'TESC Plays Nethack' (or TPN) is part of a compsec exercise put on by The Evergreen State College. As a service that needs to be defended by the blue team, these bots add "users" to the narrative.
# `TESC Plays Nethack' bot
# arg 1 = irc nick
# args 1< = additional phrases
require 'cinch'
ircnick = ARGV[0]
class NethackCommands
include Cinch::Plugin
# every 10 seconds, call 'timed'
timer 10, method: :timed
def timed
commands = ["h","j","k","l","y","u","b","n"] # nethack movement
ircnick = ARGV[0]
ARGV.each do |a|
commands << "#{a}" # additional cmdline args are added to phrase list
end
commands.delete(ircnick) # remove nick from phraselist
sleep rand(600) # variation between posting times
Channel("#tescplaysnethack").send commands.sample
end
end
bot = Cinch::Bot.new do
configure do |c|
c.server = "irc.freenode.net"
c.channels = ["#tescplaysnethack"]
c.realname = ircnick
c.nick = ircnick
c.user = ircnick
c.plugins.plugins = [NethackCommands]
end
end
bot.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment