Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require "cinch"
- require "open-uri"
- require "nokogiri"
- require "cgi"
- require "wolfram"
- if not defined?(Ocra)
- Wolfram.appid = "IP WOLFRAMA"
- ADMIN = "Linux_Shines"
- TESTING = false
- USE_MY_NICK = true
- if USE_MY_NICK == true
- PORT = 5000
- BOT_NICK = ADMIN
- BOT_REALNAME = ADMIN
- SERVER_NAME = "alldev.eu"
- elsif USE_MY_NICK == false
- PORT = 6667
- BOT_NICK = "Jean_Paul_Secundo"
- BOT_REALNAME = "Jean Paul Secundo"
- SERVER_NAME = "irc.pirc.pl"
- end
- BOT_USER = BOT_REALNAME
- PASSWORD = "HASEŁKO"
- HOP_REGEX = /^!hop (.+)/i
- LENNYFACE = "( ͡° ͜ʖ ͡°)"
- LENNY_REGEX = /\blenny(face)?\b/i
- WYKOP_REGEX = /^*wykop(.+)/i
- WOLFRAM_REGEX = /\A% (?<query>.*)\z/i
- DELETE_ACCOUNT = /\busu(n|ń konto)?\b/i
- if TESTING == false
- CHANNEL_NAME = "#mirkofm"
- elsif TESTING == true
- CHANNEL_NAME = "#testingchannel"
- end
- GOOGLE_REGEX = /^!g (.+)/i
- bot = Cinch::Bot.new do
- helpers do
- def is_admin?(user)
- true if user.nick == ADMIN
- end
- def google(query)
- url = "http://www.google.pl/search?q=#{CGI.escape(query)}"
- res = Nokogiri::HTML(open(url)).at("h3.r")
- title = res.text
- link = res.at('a')[:href]
- desc = res.at("./following::div").children.first.text
- rescue
- "Nie znaleziono żadnych wyników."
- else
- CGI.unescape_html(CGI.unescape("#{title} - #{desc} (#{link})")).force_encoding("ISO-8859-2").encode("UTF-8")
- #"#{title} - #{desc} (#{link})")
- #.force_encoding('ISO-8859-2').encode('UTF-8')
- end
- end
- configure do |c|
- c.server = SERVER_NAME
- c.port = PORT
- c.channels = [CHANNEL_NAME]
- c.nick = BOT_NICK
- c.realname = BOT_REALNAME
- c.user = BOT_USER
- c.password = PASSWORD
- end
- on :join do |m|
- if USE_MY_NICK == false
- bot.irc.send "MODE " + BOT_NICK + " +B"
- if m.user.to_s.downcase == BOT_NICK.downcase
- bot.Channel(CHANNEL_NAME).send("Po maturze chodziliśmy na... dziwki. ( ͡° ͜ʖ ͡°)\n ~Jean Paul Secundo")
- end
- end
- end
- on :kick do
- bot.Channel(CHANNEL_NAME).join
- end
- on :ban do
- bot.irc.send("MSG CHANSERV unban #{CHANNEL_NAME} #{BOT_NICK}")
- end
- if TESTING == true
- on :message, "test" do |m|
- m.reply("Testowana wiadomość skierowana do użytkownika #{m.user.nick}")
- end
- end
- on :message, WOLFRAM_REGEX do |m|
- query = WOLFRAM_REGEX.match(m.message)[:query]
- result = Wolfram.fetch(query)
- # puts result
- hash = Wolfram::HashPresenter.new(result).to_hash
- # puts hash
- m.reply(hash[:pods]['Result'][0] || "Nie.", true)
- end
- on :message, GOOGLE_REGEX do |m, query|
- m.reply google(query)
- end
- on :message, "wykop" do |m|
- m.reply("Obraża papieża.")
- end
- on :message, LENNYFACE do |m|
- if m.user.to_s.downcase == ADMIN.downcase
- m.reply("( ͡° ͜ʖ ͡°)")
- else
- m.reply("NIE DLA PSA LENNYFACE. ( ͡° ͜ʖ ͡°)")
- end
- end
- on :message, LENNY_REGEX do |m|
- if m.user.to_s.downcase == ADMIN.downcase
- m.reply("( ͡° ͜ʖ ͡°)")
- else
- m.reply("NIE DLA PSA LENNYFACE. ( ͡° ͜ʖ ͡°)")
- end
- end
- on :message, HOP_REGEX do |m|
- m.reply("sam se kurna skacz")
- end
- on :message, WYKOP_REGEX do |m|
- m.reply("Więc to tutaj obraża się papieża!")
- end
- on :message, DELETE_ACCOUNT do |m|
- # m.reply("sam se usuń")
- m.reply("sam se usuń")
- bot.irc.send("kick #{CHANNEL_NAME} #{m.user.nick} sam se usuń")
- end
- end
- bot.start
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement