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

file 62 lines (51 sloc) 1.568 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
# russian-roulette.rb

# Kicks people based on public PRIVMSG regexps.

# By Pistos - irc.freenode.net#mathetes

# This is not a standalone Ruby script; it is meant to be run from Reby
# (http://purepistos.net/eggdrop/reby).

class RussianRoulette
    REASONS = [
        'You just shot yourself!',
        'Suicide is never the answer.',
        'If you wanted to leave, you could have just said so...',
        "Good thing these aren't real bullets...",
        "That's gotta hurt...",
    ]
    ALSO_BAN = true
    BAN_TIME = 1 # minutes
    
    def initialize
        $reby.bind( "pub", "-", "!roulette", "pullTrigger", "$roulette" )
    end
    
    def put( message, destination = ( @channel || 'Pistos' ) )
        $reby.putserv "PRIVMSG #{destination} :#{message}"
    end
    
    def pullTrigger( nick, userhost, handle, channel, args )
        @channel = channel
        
        put '*spin* ...'
        sleep 4
        has_bullet = ( rand( 6 ) == 0 )
        if has_bullet
            if ALSO_BAN
                $reby.newban(
                    nick,
                    "RussianRoulette",
                    "Russian Roulette; for #{BAN_TIME} minute(s).",
                    BAN_TIME
                )
            end
            kick nick
        else
            put "-click-"
        end
    end
    
    def kick( victim )
        $reby.putkick(
            @channel,
            [ victim ],
            '{ *BANG* ' +
                REASONS[ rand( REASONS.size ) ] +
            '}'
        )
    end
    
end

$roulette = RussianRoulette.new
Something went wrong with that request. Please try again.