aboutsummaryrefslogtreecommitdiff
path: root/atmisc.tcl
diff options
context:
space:
mode:
authorGravatar fireonlive2024-08-09 19:04:10 +0000
committerGravatar steering72532024-10-23 00:39:49 -0600
commit985dcb2901d2527b79976df787035425294200b9 (patch)
treed49caf539627b062c3e8406854ffbc214804661c /atmisc.tcl
init
Diffstat (limited to 'atmisc.tcl')
-rw-r--r--atmisc.tcl136
1 files changed, 136 insertions, 0 deletions
diff --git a/atmisc.tcl b/atmisc.tcl
new file mode 100644
index 0000000..1ebcf9c
--- /dev/null
+++ b/atmisc.tcl
@@ -0,0 +1,136 @@
+bind pub * "!c" conoops
+
+proc conoops {nick uhost hand chan text} {
+ if {$chan eq "#archivebot"} {
+ if {[isvoice $nick $chan] || [isop $nick $chan]} {
+ putserv "PRIVMSG $chan :oops, $nick! try !con :c"
+ } else {
+ putserv "PRIVMSG #fire-trail :\[atmisc\] ignored \"!c $text\" from $nick!$uhost in $chan - not a voice or an op"
+ }
+ }
+}
+
+bind pub * "!statussy" statussy
+# the following three for systwi
+bind pub * "!statys" statussy
+bind pub * "!statis" statussy
+bind pub * "!s" statussy
+
+proc statussy {nick uhost hand chan text} {
+ if {$chan eq "#archivebot"} {
+ if {[isvoice $nick $chan] || [isop $nick $chan]} {
+ putserv "PRIVMSG $chan :!status $text"
+ } else {
+ putserv "PRIVMSG #fire-trail :\[atmisc\] ignored \"!statussy/!statys/!statis/!s $text\" from $nick!$uhost in $chan - not a voice or an op"
+ }
+ }
+}
+
+bind pub * "!help" abhelp
+
+proc abhelp {nick uhost hand chan text} {
+ if {$chan eq "#archivebot"} {
+ putserv "PRIVMSG $chan :$nick: see https://archivebot.readthedocs.io/"
+ }
+}
+
+
+bind pub * "!ignores" ignores
+bind pub * "!igs" ignores
+
+proc ignores {nick uhost hand chan text} {
+ if {$chan eq "#archivebot"} {
+ if {[isvoice $nick $chan] || [isop $nick $chan]} {
+ putserv "PRIVMSG $chan :$nick: http://archivebot.com/ignores/$text?compact=true"
+ } else {
+ putserv "PRIVMSG #fire-trail :\[atmisc\] ignored \"!ignores/!igs $text\" from $nick!$uhost in $chan - not a voice or an op"
+ }
+ }
+}
+
+package require uri
+
+proc loadPublicSuffixList {filename} {
+ set publicSuffixList [dict create]
+ set file [open $filename]
+ while {[gets $file line] >= 0} {
+ if {[string trim $line] eq "" || [string index $line 0] eq "/" || [string index $line 0] eq "!"} {
+ continue
+ }
+ # Normalize the line for processing
+ set line [string map {"*." ""} $line]
+ dict set publicSuffixList $line 1
+ }
+ close $file
+ return $publicSuffixList
+}
+
+proc extractRegistrableDomain {domain publicSuffixList} {
+ set parts [split $domain "."]
+ set partCount [llength $parts]
+
+ for {set i 0} {$i < $partCount} {incr i} {
+ set suffix [join [lrange $parts $i end] "."]
+ if {[dict exists $publicSuffixList $suffix]} {
+ if {$i > 0} {
+ return [join [lrange $parts [expr {$i - 1}] end] "."]
+ } else {
+ return $domain
+ }
+ }
+ }
+ return $domain
+}
+
+
+set PSLfilename "public_suffix_list.dat"
+set thePSL [loadPublicSuffixList $PSLfilename]
+
+bind pub * "!igd" igd
+
+proc igd {nick uhost hand chan text} {
+ if {$chan eq "#archivebot"} {
+ if {[isvoice $nick $chan] || [isop $nick $chan]} {
+ global thePSL
+ set components [uri::split $text]
+ set hostname [dict get $components "host"]
+ set registrableDomain [extractRegistrableDomain $hostname $thePSL]
+ set escapedDomain [string map { "." "\\." } $registrableDomain]
+ putserv "PRIVMSG $chan :$nick: ^(http|ftp)s?://(\[^/\]*\[@.\])?$escapedDomain\\.?(:\\d+)?/"
+ } else {
+ putserv "PRIVMSG #fire-trail :\[atmisc\] ignored \"!igd $text\" from $nick!$uhost in $chan - not a voice or an op"
+ }
+ }
+}
+
+bind pub * "!b" bmeme
+
+proc bmeme {nick uhost hand chan text} {
+ putserv "PRIVMSG $chan :🅱️"
+}
+
+bind pub * "!ping" pingcmd
+
+proc pingcmd {nick uhost hand chan text} {
+ if {$text eq ""} {
+ putserv "PRIVMSG $chan :$nick: pong!"
+ } else {
+ putserv "PRIVMSG $chan :$nick: pong ($text)!"
+ }
+}
+
+bind pub * "!ß" punycode
+
+proc punycode {nick uhost hand chan text} {
+ putserv "PRIVMSG $chan :...scheiße!"
+ putserv "PRIVMSG $chan :UnicodeError: ('IDNA does not round-trip', b'xn--scheie-fta', b'scheisse')"
+}
+
+bind pub * !z utctime
+bind pub * !utc utctime
+
+proc utctime {nick uhost hand chan text} {
+ set now [clock seconds]
+ set iso_time [clock format $now -format "%Y-%m-%dT%H:%M:%SZ" -gmt true]
+ putserv "PRIVMSG $chan :$iso_time"
+}