Skip to content

Instantly share code, notes, and snippets.

@clooth
Created December 26, 2011 02:18
Show Gist options
  • Save clooth/1520403 to your computer and use it in GitHub Desktop.
Save clooth/1520403 to your computer and use it in GitHub Desktop.
Join a channel on invite with a twist, Cinch Plugin
#
# Mirras Runescape IRC Bot
# Author: Clooth <[email protected]>
# Feature: InviteJoiner
# Somewhat fun way to allow the bot to join channels on invite
#
class InviteJoiner
include Cinch::Plugin
include Authentication
def initialize(*args)
super
@permission_asked = false
@asked_channel = nil
# Give the bot permission to join
@positive_answers = [
"yeh", "ok", "sure", "yeah", "yes", "kk", "go on",
"why not", "maybe this time", "don't be too late",
"come back for dinner"
]
# Don't give permission
@negative_answers = [
"no", "nope", "noep", "noep lol", "lolno", "fuck no",
"you wish", "stfu", "not this time", "no they're assholes"
]
# Possible replies by the bot in case given permission
@positive_responses = [
"Yay!", "Thanks dad! <3", "Woot!", "Awesome!", "I'm going in...",
"I'll be good!"
]
# Possible replies by the bot in case not given permission
@negative_responses = [
"Okay :(", ":'(", "Asshole.", "Fine.", "You never loved me anyway.",
"Whatever.", "I didn't want to anyway.", "They probably didn't have cookies anyway.",
"I suppose I could've been exploited sexually."
]
end
listen_to :invite, :method => :join_on_invite
def join_on_invite(message)
# If we haven't asked for permission yet
if @permission_asked == false
Channel("#mirras").send("Hey, #{message.user.nick} wants me to join #{message.channel}, can I go?")
@permission_asked = true
@asked_channel = message.channel
end
end
listen_to :message, :method => :deal_with_responses
def deal_with_responses(message)
# Should we do anything?
return unless @permission_asked == true
return unless is_admin?(message.user)
# Were we shown green light?
unless message.message.scan(/^(#{@positive_answers.join('|')})$/).empty?
Channel("#mirras").send(@positive_responses[rand(@positive_responses.size)])
bot.join(@asked_channel)
@permission_asked = false
@asked_channel = nil
return
end
# No?
unless message.message.scan(/^(#{@negative_answers.join('|')})$/).empty?
Channel("#mirras").send(@negative_responses[rand(@negative_responses.size)])
@permission_asked = false
@asked_channel = nil
return
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment