PHP Kod: Kodu kopyalamak için üzerine çift tıklayın!
#### IRC log tutucu IUC Aralık 2025 ####
# Bu script kanal içerisinde tüm aktivitleri MySQL/mariaDB bazlı log tutar
# Bunun için mysqltcl paketine ihtiyacınız bulunmaktadır
# Kullanım:
# #kanal da aktif edebilmeniz için:
# .chanset #channel +dblog
# Otomatik loglamayı aktif edebilmeniz için (Botun kanal içerisinde bütün konuşmaları ve aksyonları loglaması için):
# .chanset #channel +logme
## Konfigürasyon ##
namespace eval irclogger {
variable db
# Database ayarları
set db {
"host" "127.0.0.1"
"port" "3306"
"base" "eggdrop"
"user" "eggdrop"
"pass" "*********"
"table" "irc_logs"
}
# muaf Kullanıcı maskeleri için (daha sonraki kullanım için)
variable ignore {"services.dal.net"}
}
## KOD BAŞLIYOR##
# Burdan sonra ne yaptığınızı bilmiyorsanız dokunmayın çalışmaz
namespace eval irclogger {
variable dbconn
variable cnx
package require mysqltcl
setudef flag dblog
setudef flag logme
variable sauthor "IUC <Aralık 2025>"
variable sname "IRC Log tutucu"
variable sversion "1.0"
proc init {} {
if {![string match *account-notify* [cap enabled]] && [string match -nocase *account-notify* [cap ls]]} {
cap req account-notify
}
array set ::irclogger::dbconn $::irclogger::db
::irclogger::db.create
putlog "$::irclogger::sname V$::irclogger::sversion by $::irclogger::sauthor yüklendi"
}
# Normal prosüdür
proc logpubm {nick uhost handle chan text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "PUB" $text
}
}
proc logact {nick uhost handle chan key text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "AKSİYON" $text
}
}
proc lognick {nick uhost handle chan newnick} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "LAKAB" "" $newnick
}
}
proc logjoin {nick uhost handle chan} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "KATILDI" ""
}
}
proc logpart {nick uhost handle chan text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "AYRILDI" $text
}
}
proc logsign {nick uhost handle chan text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "ÇIKTI" $text
}
}
proc logkick {nick uhost handle chan target text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "KICKLENDİ" $text $target
}
}
proc logtopic {nick uhost handle chan text} {
if {[::irclogger::canlog $chan $nick]==1} {
::irclogger::send2db $nick $chan "TOPIC" $text
}
}
proc logme {queue message status} {
set msg[list {*}$message]
set msg [string range [join [lassign $msg mtype chan]] 1 end]
if {[validchan $chan] && [channel get $chan logme]} {
switch $mtype {
MODE {
# to do if usefull
}
PRIVMSG {
if {[string first "\001ACTION" $msg] == 0} {
set msg [string range $msg 8 end]
::irclogger::logact $::botnick * * $chan "ACTION" $msg
} else {
::irclogger::logpubm $::botnick * * $chan $msg
}
}
}
}
}
# Halka döngüsü
proc hpubm {nick chan text} { ::irclogger::logpubm $nick * * $chan $text }
proc hact {nick chan text} { ::irclogger::logact $nick * * $chan "ACTION" $text }
proc hnick {nick chan newnick} { ::irclogger::lognick $nick * * $chan $newnick }
proc hjoin {nick chan} { ::irclogger::logjoin $nick * * $chan }
proc hpart {nick chan text} { ::irclogger::logpart $nick * * $chan $text }
proc hsign {nick chan text} { ::irclogger::logsign $nick * * $chan $text }
proc hkick {nick chan target text} { ::irclogger::logkick $nick * * $chan $target $text }
proc htopic {nick chan text} { ::irclogger::logtopic $nick * * $chan $topic }
# Bazı yardımcı programlar
# Data loglanacaksa kontrol eder
proc canlog {chan nick} {
if {[channel get $chan dblog] && (![isbotnick $nick] || ([isbotnick $nick] && [channel get $chan logme])) && $nick ne "*"} {
return 1
} else {
return 0
}
}
# Eğer müsait değilse kayıtı red eder
proc nickoraccount {nick} {
if {![string match *account-notify* [cap enabled]]} { return $nick }
set acc [getaccount $nick]
if { $acc eq ""} { return $nick }
return $acc
}
# Database
proc db.open {} {
set ::irclogger::cnx [::mysql::connect -host $::irclogger::dbconn(host) -port $::irclogger::dbconn(port) -user $::irclogger::dbconn(user) -password $::irclogger::dbconn(pass) -encoding binary]
if {[::mysql::state $::irclogger::cnx] < 3} {
::irclogger::db.close
} else {
::mysql::use $::irclogger::cnx $::irclogger::dbconn(base)
}
}
proc db.close {} {
::mysql::close $::irclogger::cnx
unset -nocomplain ::irclogger::cnx
}
proc db.create {} {
::irclogger::db.open
set tables [split [::mysql::info $::irclogger::cnx tables]]
if {[lsearch -exact $tables $::irclogger::dbconn(table)] == -1} {
set qcreate "CREATE TABLE $::irclogger::dbconn(table) ( \
channel varchar(250) NOT NULL, \
eggdrop varchar(32) NOT NULL, \
ts datetime NOT NULL, \
type varchar(20) NOT NULL, \
nick varchar(32) NOT NULL, \
rawc text NOT NULL DEFAULT '', \
content text NOT NULL DEFAULT '', \
len int(20) NOT NULL, \
target varchar(32) NOT NULL \
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
::mysql::exec $::irclogger::cnx $qcreate
set qindex "ALTER TABLE $::irclogger::dbconn(table) \
ADD KEY channel (channel), \
ADD KEY nick (nick);"
::mysql::exec $::irclogger::cnx $qindex
}
::irclogger::db.close
}
proc send2db { nick chan type text {target ""}} {
set ts [clock format [clock seconds] -format "%G-%m-%d %T"]
set dnick [::irclogger::nickoraccount $nick]
set stripped [stripcodes bcruag $text]
regsub -all -- {[^\w\s]} $stripped {} stripped
set len [llength [split [string trim $stripped]]]
::irclogger::db.open
::mysql::exec $::irclogger::cnx "INSERT INTO $::irclogger::dbconn(table) (channel, eggdrop, ts, type, nick, rawc, content, len, target) VALUES ('$chan', '$::botnick', '$ts', '$type', '[::mysql::escape $::irclogger::cnx $dnick]', '[::mysql::escape $::irclogger::cnx $text]', '[::mysql::escape $::irclogger::cnx $stripped]', $len, '[::mysql::escape $::irclogger::cnx $target]')"
::irclogger::db.close
}
# Normal binds
bind pubm - * ::irclogger::logpubm
bind ctcp - "ACTION" ::irclogger::logact
bind nick - * ::irclogger::lognick
bind join - * ::irclogger::logjoin
bind part - * ::irclogger::logpart
bind sign - * ::irclogger::logsign
bind kick - * ::irclogger::logkick
bind topc - * ::irclogger::logtopic
bind out - "% sent" ::irclogger::logme
if {![catch {package require hook}]} {
hook bind logger pubm irclogger ::irclogger::hpubm
hook bind logger action irclogger ::irclogger::hact
hook bind logger nick irclogger ::irclogger::hnick
hook bind logger join irclogger ::irclogger::hjoin
hook bind logger part irclogger ::irclogger::hpart
hook bind logger sign irclogger ::irclogger::hsign
hook bind logger kick irclogger ::irclogger::hkick
hook bind logger topic irclogger ::irclogger::htopic
}
::irclogger::init
}