Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'socket'
- TWITCH_HOST = "irc.twitch.tv"
- TWITCH_PORT = 6667
- class TwitchBot
- def initialize
- @nickname = "James200024bot"
- @password = "oauth:jkffmog2xf0zj1smj3ie3tj7us9i3d"
- @channel = "James200024"
- @socket = TCPSocket.open(TWITCH_HOST, TWITCH_PORT)
- write_to_system "PASS #{@password}"
- write_to_system "NICK #{@nickname}"
- write_to_system "USER #{@nickname} 0 * #{@nickname}"
- write_to_system "JOIN ##{@channel}"
- end
- def write_to_system(message)
- @socket.puts message
- end
- def write_to_chat(message)
- write_to_system "PRIVMSG ##{@channel} :#{message}"
- end
- def run
- until @socket.eof? do
- message = @socket.gets
- puts message
- if message.match(/^PING :(.*)$/)
- write_to_system "PONG #{$~[1]}"
- next
- end
- if message.match(/PRIVMSG ##{@channel} :(.*)$/)
- content = $~[1]
- username = message.match(/@(.*).tmi.twitch.tv/)[1]
- # if content.include? "!James"
- # write_to_chat("James is a plank")
- # if content.include? "!Discord"
- # write_to_chat("https://discord.gg/quYaMPS Join the discord today , and enjoy the fun ;)")
- # if content.include? "!Twitter"
- # write_to_chat("James200024 Go and follow him on Twitter for all the latest updates!")
- # if content.include? "!Instagram"
- # write_to_chat("James200024 Go and follow him on Instagram for all the latest posts!")
- # if content.include? "!Steam"
- # write_to_chat("James200024 Go and him on Steam for all the mp fun")
- # if content.include? "!YouTube"
- # write_to_chat("James200024 is the youtube <> go and subscribe and join in the fun by watching the videos")
- # end
- command = <<-OSASCRIPT
- osascript -e 'display notification "#{content}" with title "#{username}"'
- OSASCRIPT
- system(command)
- end
- end
- end
- def quit
- write_to_chat "James200024bot is out"
- write_to_system "PART ##{@channel}"
- write_to_system "QUIT"
- end
- end
- bot = TwitchBot.new
- trap("INT") { bot.quit }
- bot.run
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement