Sha256: e1a8bc2916ad72269ec1b68c893129060da266015f523fed1eb942dfe3ff5d08

Contents?: true

Size: 986 Bytes

Versions: 2

Compression:

Stored size: 986 Bytes

Contents

#!/usr/bin/env ruby
require 'fantasy-irc'

# new connection
bot = Fantasy::IRC.new

# load some plugins
bot.plugins.load 'corecommands'

# log in once we are connected
connected = Proc.new do
	bot.login :nickname => "example", :username => "example", :realname => "GECOS field"
end
bot.events.by_name('connected').register &connected

# join a room and say hi
loggedin = Proc.new do
	%w{#lobby}.each do |r|
		room = bot.rooms.new(r).join.say "ohai"
	end
end
bot.events.by_name('loggedin').register &loggedin

# we also want to greet users that are joining the room
user_joined = Proc.new do |room, user|
	room.say("Hey, #{user.name}!")
end
bot.events.by_name('user_joined').register &user_joined

# and monitor everything they say
channel_message = Proc.new do |room, user, text|
	puts "!! #{user.name} said in room #{room.name}: #{text}"
end
bot.events.by_name('channel_message').register &channel_message

bot.connect :server => "irc.example.com", :ssl => true, :port => 6697
bot.run

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fantasy-irc-0.1.1 docs/example.rb
fantasy-irc-0.1.0 docs/example.rb