<commit_before>#|
 This file is a part of Colleen
 (c) 2013 TymoonNET/NexT http://tymoon.eu (<EMAIL>)
 Author: <NAME> <<EMAIL>>
|#

(in-package :org.tymoonnext.colleen)
(defpackage org.tymoonnext.colleen.mod.silly
  (:use :cl :colleen :events))
(in-package :org.tymoonnext.colleen.mod.silly)

(define-module silly ()
    ((%active-in :initform () :accessor active-in))
  (:documentation "Silly things."))

(defparameter *save-file* (merge-pathnames "silly.json" (merge-pathnames "config/" (asdf:system-source-directory :colleen))))
(defparameter *thanks-match* (cl-ppcre:create-scanner "[Tt]hanks[,]? ([a-zA-Z]+)$"))
(defparameter *bless-match* (cl-ppcre:create-scanner "[Bb]less you[,]? ([a-zA-Z]+)$"))

(defun cut-to-first-vocal (string)
  (loop for i from 0 below (length string)
        until (find (aref string i) '(#\a #\e #\i #\o #\u))
        finally (return (subseq string i))))

(defmethod start ((silly silly))
  (with-open-file (stream *save-file* :if-does-not-exist NIL)
    (when stream
      (setf (active-in silly) (yason:parse stream)))))

(defmethod stop ((silly silly))
  (with-open-file (stream *save-file* :direction :output :if-does-not-exist :create :if-exists :supersede)
    (yason:encode (active-in silly) stream)))

(define-group silly :documentation "Manage the silly module.")

(define-command (silly activate) (&optional channel server) (:authorization T :documentation "Activate the silly responses for the channel.")
  (unless channel (setf channel (channel event)))
  (unless server (setf server (name (server event))))
  (pushnew (format T "~a/~a" server channel) (active-in module) :test #'string-equal)
  (respond event "Activated silliness."))

(define-command (silly deactivate) (&optional channel server) (:authorization T :documentation "Deactivate the silly responses for the channel.")
  (unless channel (setf channel (channel event)))
  (unless server (setf server (name (server event))))
  (setf (active-in module) (delete (format T "~a/~a" server channel) (active-in module) :test #'string-equal))
  (respond event "Deactivated silliness."))

(define-handler (privmsg-event event) ()
  (when (member (format T "~a/~a" (name (server event)) (channel event)) (active-in module) :test #'string-equal)
    (let ((message (string-downcase (message event))))
      (cl-ppcre:register-groups-bind (name) (*thanks-match* message)
        (sleep 2)
        (respond event "...Th~a" (cut-to-first-vocal name)))
      (cl-ppcre:register-groups-bind (name) (*bless-match* message)
        (sleep 2)
        (respond event "...Bl~a" (cut-to-first-vocal name)))
      
      (when (cl-ppcre:scan "^colleen: (and )?(oh )?i (love|luv|wub) (you|u|wu|wuu|wo|woo)( too)?( as well)?( (so|very|too)( much)?)?$" message)
        (respond event (format NIL "~a: ~a ~a" 
                               (nick event) 
                               (alexandria:random-elt '("I love you too." "Aww!" "Oh you~~" "Haha, oh you." "I wub wuu twoo~~" "I love you too!" "Tee hee." "I love you too."))
                               (alexandria:random-elt '("" "" "" "" ":)" "(ɔˆ ³(ˆ⌣ˆc)" "(ღ˘⌣˘ღ)" "(っ˘з(˘⌣˘ )" "(˘▼˘>ԅ( ˘⌣ƪ)")))))

      (when (or (cl-ppcre:scan "(i|you|he|she|it|we|they)( all)? know(s?) now" message)<commit_msg>What the hell was I doing<commit_after>#|
 This file is a part of Colleen
 (c) 2013 TymoonNET/NexT http://tymoon.eu (<EMAIL>)
 Author: <NAME> <<EMAIL>>
|#

(in-package :org.tymoonnext.colleen)
(defpackage org.tymoonnext.colleen.mod.silly
  (:use :cl :colleen :events))
(in-package :org.tymoonnext.colleen.mod.silly)

(define-module silly ()
    ((%active-in :initform () :accessor active-in))
  (:documentation "Silly things."))

(defparameter *save-file* (merge-pathnames "silly.json" (merge-pathnames "config/" (asdf:system-source-directory :colleen))))
(defparameter *thanks-match* (cl-ppcre:create-scanner "[Tt]hanks[,]? ([a-zA-Z]+)$"))
(defparameter *bless-match* (cl-ppcre:create-scanner "[Bb]less you[,]? ([a-zA-Z]+)$"))

(defun cut-to-first-vocal (string)
  (loop for i from 0 below (length string)
        until (find (aref string i) '(#\a #\e #\i #\o #\u))
        finally (return (subseq string i))))

(defmethod start ((silly silly))
  (with-open-file (stream *save-file* :if-does-not-exist NIL)
    (when stream
      (setf (active-in silly) (yason:parse stream)))))

(defmethod stop ((silly silly))
  (with-open-file (stream *save-file* :direction :output :if-does-not-exist :create :if-exists :supersede)
    (yason:encode (active-in silly) stream)))

(define-group silly :documentation "Manage the silly module.")

(define-command (silly activate) (&optional channel server) (:authorization T :documentation "Activate the silly responses for the channel.")
  (unless channel (setf channel (channel event)))
  (unless server (setf server (name (server event))))
  (pushnew (format NIL "~a/~a" server channel) (active-in module) :test #'string-equal)
  (respond event "Activated silliness."))

(define-command (silly deactivate) (&optional channel server) (:authorization T :documentation "Deactivate the silly responses for the channel.")
  (unless channel (setf channel (channel event)))
  (unless server (setf server (name (server event))))
  (setf (active-in module) (delete (format NIL "~a/~a" server channel) (active-in module) :test #'string-equal))
  (respond event "Deactivated silliness."))

(define-handler (privmsg-event event) ()
  (when (member (format NIL "~a/~a" (name (server event)) (channel event)) (active-in module) :test #'string-equal)
    (let ((message (string-downcase (message event))))
      (cl-ppcre:register-groups-bind (name) (*thanks-match* message)
        (sleep 2)
        (respond event "...Th~a" (cut-to-first-vocal name)))
      (cl-ppcre:register-groups-bind (name) (*bless-match* message)
        (sleep 2)
        (respond event "...Bl~a" (cut-to-first-vocal name)))
      
      (when (cl-ppcre:scan "^colleen: (and )?(oh )?i (love|luv|wub) (you|u|wu|wuu|wo|woo)( too)?( as well)?( (so|very|too)( much)?)?$" message)
        (respond event (format NIL "~a: ~a ~a" 
                               (nick event) 
                               (alexandria:random-elt '("I love you too." "Aww!" "Oh you~~" "Haha, oh you." "I wub wuu twoo~~" "I love you too!" "Tee hee." "I love you too."))
                               (alexandria:random-elt '("" "" "" "" ":)" "(ɔˆ ³(ˆ⌣ˆc)" "(ღ˘⌣˘ღ)" "(っ˘з(˘⌣˘ )" "(˘▼˘>ԅ( ˘⌣ƪ)")))))

      (when (or (cl-ppcre:scan "(i|you|he|she|it|we|they)( all)? know(s?) now" message)
{'fraction_non_alphanumeric': 0.1881918819188192, 'fraction_numerical': 0.002152521525215252, 'mean_word_length': 3.7620790629575405, 'pattern_counts': {'":': 2, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1412202', 'n_tokens_mistral': 2387, 'n_tokens_neox': 2303, 'n_words': 636}