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"
- Wolfram.appid = "CHUJ CI DO TEGO, ZAPYTAĆ SIĘ MOŻESZ"
- ADMIN = "Linux_Shines"
- TESTING = false
- BOT_NICK = "Lunux_"
- BOT_REALNAME = "Jean Paul Secundo"
- BOT_USER = "Lunux_"
- PASSWORD = "HASŁO"
- HOP_REGEX = /^!hop (.+)/i
- LENNYFACE = "( ͡° ͜ʖ ͡°)"
- WOLFRAM_REGEX = /\A% (?<query>.*)\z/i
- WYKOP_REGEX = /^wykop(.+)/i
- SERVER_NAME = "irc.pirc.pl"
- 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.channels = [CHANNEL_NAME]
- c.nick = BOT_NICK
- c.realname = BOT_REALNAME
- c.user = BOT_USER
- c.password = PASSWORD
- end
- on :join do
- bot.irc.send "MODE " + BOT_NAME + " +B"
- # m.reply("A po szkole chodziliśmy na... dziwki. ( ͡° ͜ʖ ͡°)\n~Jean Paul Secundo")
- bot.Channel(CHANNEL_NAME).send("A po szkole chodziliśmy na... dziwki. ( ͡° ͜ʖ ͡°)\n~Jean Paul Secundo")
- end
- on :kick do
- bot.Channel(CHANNEL_NAME).join
- end
- on :ban do
- bot.irc.send("MSG CHANSERV unban #{CHANNEL_NAME} #{BOT_NAME}")
- 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 ADMIN == "Linux_Shines"
- m.reply("( ͡° ͜ʖ ͡°)")
- elsif # czemu kurwa to nie działa :<
- m.reply("NIE DLA PSA LENNYFACE. ( ͡° ͜ʖ ͡°)")
- end
- end
- on :message, "lennyface" do |m|
- if ADMIN == "Linux_Shines"
- m.reply("( ͡° ͜ʖ ͡°)")
- elsif # czemu kurwa to nie działa :<
- 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
- end
- bot.start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement