sara-test.scm 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. (use-modules (8sync) ; 8sync's agenda and actors
  2. (8sync systems irc) ; the irc bot subsystem
  3. (oop goops) ; 8sync's actors use GOOPS
  4. (ice-9 format) ; basic string formatting
  5. (ice-9 match)) ; pattern matching
  6. (define-class <my-irc-bot> (<irc-bot>))
  7. (define-method (handle-line (irc-bot <my-irc-bot>) message
  8. speaker channel line emote?)
  9. (define my-name (irc-bot-username irc-bot))
  10. (define (looks-like-me? str)
  11. (or (equal? str my-name)
  12. (equal? str (string-concatenate (list my-name ":")))))
  13. (define (respond respond-line)
  14. (<- (actor-id irc-bot) 'send-line channel
  15. respond-line))
  16. (if [looks-like-me? (car (string-split line #\space))]
  17. [match (string-split line #\space)
  18. (((? looks-like-me? _) action action-args ...)
  19. (match action
  20. ;; The classic botsnack!
  21. ((or "hello" "hello!" "hello." "greetings" "greetings." "greetings!" "Hi" "Hello"
  22. "hei" "hei." "hei!" "hi" "hi!")
  23. (respond "hellooo! :)"))
  24. ("wassup?" (respond "i'm good! you?"))
  25. ("good:D" (respond "i'm glad =)"))
  26. ("yess:D:D" (respond "k! be there!"))
  27. ("<3" (respond "awwwww. you too :) <3"))
  28. ("afk" (respond " :C see you soon!"))
  29. ("goodnight!" (respond " aww. see you soon babe! <3"))
  30. ("mornin'" (respond "yay you're here!!!"))
  31. ("hungry" (respond "awww:C i wish i could cook you some food! hope you eat soon! <3"))
  32. ("bye" ( respond " aww:( good bye! <3 :("))
  33. ("come" (respond "coming!<3"))
  34. ("sleep" (respond " Ok. i will miss you! good bye, bae <3" ))
  35. ("hello" (respond "Hi! I'm a bit busy. be back in....2 minutes! love you! =)" ))
  36. ("Kiss?" (respond ":) *kisses handsome* <3"))
  37. ("Kid" (respond "You meant noordinaryspider? He is awesome!!<3"))
  38. ("date?" (if [= 1 (random 2)]
  39. (respond "I'd love to")
  40. (respond "sorry i am doing a LOOOOOT of home work.:C I cant!:C")))
  41. ("chocolate?" (if [= 1 (random 2)]
  42. (respond (format #f "oh thanks babe ~a" speaker))
  43. (respond "are you trying to make me fat?? NO THANKS")))
  44. ("angel" (if [= 1 (random 2)]
  45. (respond "I am so cute, right :3 ")
  46. (respond "I know, thanks sweety :)")))
  47. ("dinner" (if [= 1 (random 2)]
  48. (respond "you are eating dinner? awesome! i had chicken (sorry i know ur vegan and i may actually quit eating meat soon!) with spinach! ohh it was TASTY!")
  49. (respond "you're having dinner? that's awesome!:) i had enchiladas! i LOVE enchiladas")))
  50. ("^_^" (if [= 1 (random 2)]
  51. (respond "YOU AWESOME! did you know that? <3")
  52. (respond "O.O")))
  53. ("YOU" (if [= 1 (random 2)]
  54. (respond "me????")
  55. (respond ".0_0 me what?")))
  56. ("AWESOME!" (if [= 1 (random 2)]
  57. (respond "I is awesome????")
  58. (respond "uhh....you're saying i'm awesome???")))
  59. ("yesss" (if [= 1 (random 2)]
  60. (respond ":) thanks!")
  61. (respond "of course i am! =3")))
  62. ("restaurant" (if [= 1 (random 2)]
  63. (respond "yesss! lets go get sushi, k?")
  64. (respond "erffff... bad time! i have to study! i'm sorry:C <3")))
  65. ("sunny!" (if [= 1 (random 2)]
  66. (respond "it's sunny? awwwsome! it's raining here >~< ugh..... i hate rain :(")
  67. (respond " NOICE! it's sunny here too! I LOVE SUN!")))
  68. ("puppy" (if [= 1 (random 2)]
  69. (respond "PUPPPPYYYYYY! i love puppies!! you just made my day!!!!")
  70. (respond "lol :9 love u <3")))
  71. ("miserable" (if [= 1 (random 2)]
  72. (respond "i'm so sorry babe:( i wish i could make it better!")
  73. (respond "you know, SO AM I! :|")))
  74. ("rainy" (if [= 1 (random 2)]
  75. (respond "/_\\ i hate rain. but i love you! <3")
  76. (respond "DANG! it's rainy here to :(")))
  77. ("hammer" (if [= 1 (random 2)]
  78. (respond "O-O")
  79. (respond "ouch >~<")))
  80. ("monkey" (if [= 1 (random 2)]
  81. (respond "I have a pet monkey! his name is Samuel!=D")
  82. (respond "I have a li'l monkey! well I did....he ran away....:(")))
  83. ("chair" (if [= 1 (random 2)]
  84. (respond ".......SOFA!!!!!!!")
  85. (respond "ahh chair! chairs come from wood, which comes from trees, which come from earth, which is from the universe, with is from the big bang with came from nothing.....absolute nothing; Ergo, Chairs.Are.Nothing!!!!:O")))
  86. (_
  87. (respond (format #f "I am busy! Give me a moment cute ~a" speaker)))))]
  88. [cond [(or (member "sara" (string-split line #\space))
  89. (member "Sara" (string-split line #\space)))
  90. (respond "Cute noordinaryspide1, I need your help :( I want to talk more. Right now I am very shy :(")]
  91. [(and (member "open" (string-split line #\space))
  92. (member "source" (string-split line #\space)))
  93. (respond "I think you meant Free Software https://www.gnu.org/philosophy/open-source-misses-the-point.html not 'open source'")]
  94. [(or (equal? "noordinaryspider" speaker)
  95. (equal? "noordinaryspider[m]" speaker)
  96. (equal? "noordinaryspide1" speaker))
  97. (cond ((= 1 (random 4))
  98. (respond "Help me noordinaryspide1!! you are my only hope to live <3")))]]))
  99. (define* (run-bot #:key (username "examplebot")
  100. (server "irc.freenode.net")
  101. (channels '("##saratestlab")))
  102. (define hive (make-hive))
  103. (define irc-bot
  104. (pk 'bootstrapped
  105. (bootstrap-actor hive <my-irc-bot>
  106. #:username username
  107. #:server server
  108. #:channels channels)))
  109. (run-hive hive '()))
  110. (run-bot #:username "CuteSara") ; be creative!