Идеята всъщност хич не е глупава. Младежа явно иска да имплементира сесийна оторизация.
За целта:
1. Забраняват се всички built-in команди - за идентифициране на хост, за получаване на voice/op и т.н.
2. Премахват се всички add-нати хостове на потребителите.
3. Разработва се алгоритъм за идентифициране на потребител по следния начин:
3.1 Потребителя се оторизира пред бота с указана парола
3.2 Добавя се временен хост, който е валиден до:
3.2.1 Използване на команда за деоторизация
3.2.2 Напускане на канала
3.2.3 Излизане от IRC
4. След като потребителя е успешно оторизиран му се дава достъп до командите, които трябва да ползва.
Ето пример (непълен) от това, което съм събирал преди време от разни скриптове:
CODE
# Use @ your own risk.
# Setting some requirements
package require Tcl 8.3
package require eggdrop 1.6
#defining namespace
namespace eval chanlock {
global botnick
# dealing with some variables
variable auth_clones 1
variable botnick $botnick
# dealing with auth
# definning auth_ok process
proc authok {nick host hand} {
variable auth_clones
if { [validuser $hand] == 0 } { return 0 }
if { [getuser $hand XTRA auth] < 1 } { return 0 }
if { [getuser $hand XTRA authhost] != $host } { return 0 }
if { $auth_clones == 1 && [getuser $hand XTRA authnick] != $nick} { return 0 }
return 1
}
proc auth_timer {hand} {
if { [hand2nick $hand] != "" } { return 0 }
set a [getuser $hand XTRA auth]
if { $a != 0 } {
setuser $hand XTRA auth 0
putcmdlog "\002\[AUTH\]\002 $hand didn't (re)join a chan in time."
if { $a == 2 } {
set tmphost "*![getuser $hand XTRA authhost]"
delhost $hand $tmphost
putcmdlog "\002\[AUTH\]\002 Temporary hostmask $tmphost removed from $hand."
}
}
}
proc msg_auth {nick host hand arg} {
variable auth_clones
set ahand [lindex $arg 0]
set pw [lindex $arg 1]
# unknown handle, no password or false password -> no auth
if { [validuser $ahand] == 0 } { return 0 }
if { [passwdok $ahand ""] == 1 } { return 0 }
if { [passwdok $ahand $pw] == 0 } { return 0 }
if { [getuser $ahand XTRA auth] == 2 } {
set tmphost "*![getuser $ahand XTRA authhost]"
delhost $ahand $tmphost
setuser $ahand XTRA auth 0
putcmdlog "\002\[AUTH\]\002 Temporary hostmask $tmphost removed from $ahand."
putnotc $nick "\002\[AUTH\]\002 Removed old pending auth. Please try again!"
return 0
}
setuser $ahand XTRA authhost $host
if { $auth_clones == 1 } {
setuser $ahand XTRA authnick $nick
}
if { $hand != $ahand } {
# We need to temporarly add $hand's hostmast to $ahand
setuser $ahand HOSTS "*!$host"
setuser $ahand XTRA auth 2
putcmdlog "\002\[AUTH\]\002 $nick identified as $ahand with temporary hostmask *!$host"
} {
setuser $ahand XTRA auth 1
putcmdlog "\002\[AUTH\]\002 $nick identified as $ahand with known host $host"
}
putnotc $nick "\002\[AUTH\]\002 Auth granted !!!"
if { [nick2hand $nick] == "" } {
putnotc $nick "\002\[AUTH\]\002 You must soon join one of my chans or your auth will be removed."
utimer 66 "auth_timer $ahand"
}
return 0
}
proc msg_unauth {nick host hand arg} {
variable auth_clones
set ahand [lindex $arg 0]
set pw [lindex $arg 1]
# unknown handle, no password or false password -> no auth
if { [validuser $ahand] == 0 } { return 0 }
if { [passwdok $ahand ""] == 1 } { return 0 }
if { [passwdok $ahand $pw] == 0 } { return 0 }
set tmphost "*![getuser $ahand XTRA authhost]"
delhost $ahand $tmphost
setuser $ahand XTRA auth 0
putcmdlog "\002\[AUTH\]\002 Temporary hostmask $tmphost removed from $ahand."
putnotc $nick "\002\[AUTH\]\002 Auth revoked !!!"
set tmphost "*![getuser $ahand XTRA authhost]"
set tmpauth [getuser $ahand XTRA auth]
return 0
}
proc nick_auth {nick host hand chan newnick} {
if {$hand == "*"} { return 0 }
if {[getuser $hand XTRA auth] >= 1 &&
[getuser $hand XTRA authnick] == $nick} {
setuser $hand xtra authnick $newnick
}
}
proc part_auth {nick host hand chan text} {
if { $hand == "*" } { return 0 }
set a [getuser $hand XTRA auth]
if { $a >= 1 } {
utimer 10 "auth_timer $hand"
}
}
proc sign_auth {nick host hand chan reason} {
variable auth_clones
if { $hand == "*" } { return 0 }
set a [getuser $hand XTRA auth]
if { $a >= 1 } {
if { $auth_clones == 1 && [getuser $hand XTRA authnick] != $nick } {
putcmdlog "\002\[AUTH\]\002 clone signoff ($nick != $hand)"
return 0
}
setuser $hand XTRA auth 0
if { $a == 2 } {
set tmphost "*![getuser $hand XTRA authhost]"
delhost $hand $tmphost
putcmdlog "\002\[AUTH\]\002 Temporary hostmask $tmphost removed from $hand."
}
}
}
# setting all users as unauthed
foreach u [userlist] { setuser $u XTRA auth 0 }
# dealing with some binds here
bind msg - auth [namespace current]::msg_auth
bind msg - unauth [namespace current]::msg_unauth
if { $auth_clones == 1 } { bind nick - * [namespace current]::nick_auth }
bind sign - * [namespace current]::sign_auth
bind part - * [namespace current]::part_auth
}
Кое за какво служи:
msg_auth - процес за оторизиране пред бота
msg_unauth - процес за деоторизиране
nick_auth - процес за добавяне на новия ник, към временния host запис (управлява се, чрез стойност на променливата auth_clones: 0 - забранява добавяне на временен host запис при смяна на никнейм, != 0 - разрешава добавяне на временен host запис при смяна на никнейм)
part_auth - процес за деоторизиране при напускане на канал
sign_auth - процес за деоторизиране при напускане на IRC
authok - проверка за валидност на оторизация
По-нататък сам ще си (пре)пишеш каквото е необходимо за раздаване на кльомби, маймунки, опове и т.н.