Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'cinch'
- require 'net/http'
- require 'uri'
- bot = Cinch::Bot.new do
- configure do |conf|
- conf.server = 'irc.freenode.net'
- conf.port = 6697
- conf.messages_per_second = 1.0
- conf.sasl.username = 'pb2cpy'
- conf.sasl.password = 'REDACTED HUE HUE YOU 1337 H4XX0RS CAN"T GET ME MEOW'
- conf.ssl.use = true
- conf.channels = ['#learnprogramming', '#lpmc']
- # conf.channels = ['#botters-test']
- conf.nick = 'pb2cpy'
- conf.realname = 'Pastebin => cpy.pt'
- conf.user = 'pb2cpy'
- end
- on :message, /((http:\/\/)?pastebin\.com\/\S*)/ do |msg, pblink|
- uri = URI(pblink)
- paste = Net::HTTP.get(uri.host, "/raw#{uri.path}")
- if paste != '' then
- res = Net::HTTP.post_form(URI('https://cpy.pt/'), 'paste' => paste, 'raw' => 'false')
- token, link = res.body.chomp.split('|')
- puts "[] Delete: #{token}"
- msg.reply "repasted for #{msg.user.nick} at #{link.lstrip}"
- else
- msg.reply "God damn it #{msg.user.nick}. That link isn't valid."
- end
- end
- end
- bot.start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement