-
-
Save sr/54197 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Meh, I went overboard. Usage: | |
# | |
# To tweet, write in channel: | |
# nancie, tweet this: some nice thing about sinatra and stuff | |
# To give permissions, private message: | |
# /msg nancie allow awesome_user | |
# | |
# Additional extensions are welcome. | |
require 'rubygems' | |
require 'isaac' | |
require 'rest_client' | |
require 'yaml' | |
module Nancie | |
extend self | |
attr_reader :config | |
def load_config | |
@config = YAML.load_file('config.yml') | |
end | |
def write_config | |
File.open('config.yml', 'w') { |f| YAML.dump(@config, f) } | |
end | |
def allowed?(nick) | |
config['allowed'].include?(nick) | |
end | |
def allow!(nick) | |
@config['allowed'] << nick | |
write_config | |
end | |
end | |
Nancie.load_config | |
config do |c| | |
c.nick = 'nancie' | |
c.server = 'irc.freenode.net' | |
end | |
on :connect do | |
join '#sinatra' | |
msg 'nickserv', "identify #{Nancie.config['nickserv_password']}" | |
end | |
on :channel, /^nancie.*tweet this: (.*)/ do | |
if allowed?(nick) | |
RestClient.post "http://sinatrarb:#{Nancie.config['twitter_password']}@" + | |
"twitter.com/statuses/update.json", :status => match[1] | |
else | |
msg nick, "We're fucking ninjas! Move, bitch!" | |
end | |
end | |
on :private, /^allow (\S+)/ do | |
nick = match.firt | |
if Nancie.allowed?(nick) | |
Nancie.allow!(nick) | |
msg nick, "#{nick} has throwing stars!" | |
else | |
msg nick, "Lulz, where are your throwing stars?" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
twitter_password: something | |
nickserv_password: otherthing | |
allowed: | |
- rtomayko | |
- sr | |
- bmizerany | |
- foca | |
- cypher23 | |
- syd | |
- harryjr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment