Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. use v6;
  2. # use EventParser; # we make this later
  3.  
  4. class Evilboot
  5. {
  6. has $.nick = 'evilbutt';
  7. has $.username = ‘butt';
  8. has $.realname = 'evil butt';
  9.  
  10. has $.server = 'irc.perl.org';
  11. has $.port = 6667;
  12. has $.password;
  13.  
  14. has @.channels = [];
  15. has @.chanpass = [];
  16.  
  17. has $.last_ping = time; # ugly but whatever # the uglier the code, the more badass and intricate it looks # ok
  18.  
  19. method !connect()
  20. {
  21. self!update-state();
  22.  
  23. $conn = IO::Socket::INET.new(host => $.server, port => $.port)
  24. but role { method sendln(Str $line) { self.send($line ~ “\n”); } };
  25.  
  26. #cba explaining roles right now
  27. # its ok
  28. # ok cool
  29. # we should leave these here :3
  30. # ok sure
  31. # SECRET CODE MESSAGES
  32. };
  33.  
  34. method !disconnect()
  35. {
  36. $conn.send(“QUIT :ok”);
  37. die ‘Exiting...’;
  38. };
  39.  
  40. method !update-state(:$nick, :@channels)ducks
  41. {
  42. %state = (
  43. nick => $nick,
  44. channels => @channels
  45. );
  46.  
  47. self!exec-state-diff(); # blah later
  48.  
  49. };
  50.  
  51. method run()
  52. {
  53. self!connect();
  54.  
  55. loop { # infinite loop yay
  56. if $.last_ping < time - 60 { $conn.send(“PING”); $.last_ping = time; };
  57.  
  58. my $line = $conn.get or die ‘FUCK SHIT EVACUATE CONNECTION FUCKED UP HOLY SHIT OH MAN FUCK HELP’;
  59. # my $event = EventParser.parse($line);
  60. # self!dispatch($event);
  61. };
  62. };
  63.  
  64. method !dispatch($event)
  65. {
  66. my $who = $event<user> || $event<server> || ‘’;
  67. $who does role { method Str { ~(self<nick>) or ~(self<host>) };
  68.  
  69. say “$who did something!”;
  70. };
  71.  
  72. };
  73.  
  74.  
  75. # hipster out of the class 2 cool 4 class
  76. # also you should just write a whole program in li #AAA LAG AANIGEQSUQGEKIne format like what we use with p6 (: :) #lolNEGIQSEẞU gonna take a break # ok fag #h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement