Added Url skipping features
This commit is contained in:
parent
5b901e51a9
commit
68602f3942
@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
(defn parse-int [s] (Integer/parseInt s))
|
(defn parse-int [s] (Integer/parseInt s))
|
||||||
|
|
||||||
|
(def url-pattern
|
||||||
|
#"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))")
|
||||||
|
|
||||||
|
|
||||||
(defn tokenize-line [line]
|
(defn tokenize-line [line]
|
||||||
(let [non-char-pattern (re-pattern "[\\p{Z}\\p{C}\\p{P}]+")
|
(let [non-char-pattern (re-pattern "[\\p{Z}\\p{C}\\p{P}]+")
|
||||||
tokenize
|
tokenize
|
||||||
@ -241,6 +245,9 @@
|
|||||||
:else
|
:else
|
||||||
(do
|
(do
|
||||||
(doseq [line (sentencize-text message)]
|
(doseq [line (sentencize-text message)]
|
||||||
|
(let [urls (map first (re-seq url-pattern line))]
|
||||||
|
(if (not (empty? urls))
|
||||||
|
(doseq [url urls] (println "Url Found >" url))
|
||||||
(when-not (= 1 (count (tokenize-line line)))
|
(when-not (= 1 (count (tokenize-line line)))
|
||||||
(do
|
(do
|
||||||
(println ">" sender ":" line)
|
(println ">" sender ":" line)
|
||||||
@ -255,7 +262,7 @@
|
|||||||
(when (and
|
(when (and
|
||||||
@bot-talking?
|
@bot-talking?
|
||||||
(<= (rand) (/ 1 speak-interval)))
|
(<= (rand) (/ 1 speak-interval)))
|
||||||
(create-statement-and-send)))))
|
(create-statement-and-send)))))))
|
||||||
(when (zero? (mod @msg-count save-interval))
|
(when (zero? (mod @msg-count save-interval))
|
||||||
(println "Saving memory")
|
(println "Saving memory")
|
||||||
(save-memory bot @line-list-atom))))
|
(save-memory bot @line-list-atom))))
|
||||||
@ -334,6 +341,5 @@
|
|||||||
(parse-int min-sentence-length)
|
(parse-int min-sentence-length)
|
||||||
(parse-int max-sentence-length)))
|
(parse-int max-sentence-length)))
|
||||||
|
|
||||||
;;filter out links
|
|
||||||
;;switch to pircbotx
|
;;switch to pircbotx
|
||||||
;;pronoun substitution
|
;;pronoun substitution
|
||||||
|
Loading…
Reference in New Issue
Block a user