Guest User

Untitled

a guest
Feb 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #!/usr/bin/ruby
  2.  
  3. server = 'localhost' # 'localhost' 'irc.freenode.net'
  4. port = 6667
  5. channel = '#kolibria' # '#bidule'
  6. nick = 'jessica971'
  7.  
  8. require 'socket'
  9.  
  10. socket = TCPSocket.new server, port
  11. ["NICK #{nick}", "USER #{nick} 0 * :Jessica From Gwadada", "JOIN #{channel}"].each { |command|
  12. socket.puts command
  13. }
  14.  
  15. x=0
  16.  
  17. while line = socket.gets
  18. line.strip!
  19. if line =~ /PING/
  20. socket.puts "PONG"
  21. end
  22. puts line
  23.  
  24. if line =~ /PRIVMSG ([^ :]+) +:!(.+)/
  25. m, sender, target, command = *line.match(/:([^!]*)![^ ].* +PRIVMSG ([^ :]+) +:!(.+)/)
  26. arg = command[/[^ ]+ +(.+)/, 1]
  27. case command
  28. when /^42/
  29. msg = "The Answer to Life, the Universe, and Everything"
  30. when /^hello/
  31. msg = "#{sender} te dit bonjour, #{arg}" if arg
  32. # autres commandes
  33. #else
  34. # msg = "Unknown command"
  35. end
  36. socket.puts "PRIVMSG #{channel} :#{msg}"
  37. end
  38. end
Add Comment
Please, Sign In to add comment