BT.Egg.tcl 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. #########################################################################
  2. ## BlackTools - The Ultimate Channel Control Script ##
  3. ## One TCL. One smart Eggdrop ##
  4. #########################################################################
  5. ############################## EGG TCL ##############################
  6. #########################################################################
  7. ## ##
  8. ## BlackTools : http://blacktools.tclscripts.net ##
  9. ## Bugs report : http://www.tclscripts.net/ ##
  10. ## GitHub page : https://github.com/tclscripts/BlackToolS-TCL ##
  11. ## Online Help : irc://irc.undernet.org/tcl-help ##
  12. ## #TCL-HELP / UnderNet ##
  13. ## You can ask in english or romanian ##
  14. ## ##
  15. #########################################################################
  16. proc egg:setting_check {setting} {
  17. global black
  18. set settings "nick realname away homechan chanserv hostchanserv userlogin userpass chanremove-setting add-mask add-defaultmask user-expire banmethod-expire broadcast-showtime cmdchar defaultlang defaultoutput floodmenuprot userfloodmsgprot massfloodmsgprot massfloodsilencetime floodnotcprot pagelimit antibotidle quote-usage"
  19. if {[lsearch -exact [string tolower $settings] [string tolower $setting]] < 0} {
  20. return 0
  21. } else { return 1 }
  22. }
  23. proc egg:process {unick host hand chan chan1 setting result} {
  24. global black config nick botnick
  25. set tcl_config $black(tclconfig)
  26. switch [string tolower $setting] {
  27. nick {
  28. set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  29. set return [config:getinfo $config "set nick \"*\""]
  30. if {[string equal -nocase $return $result]} {
  31. return 2
  32. }
  33. set ::lastnick [config:getinfo $config "set nick \"*\""]
  34. set error [config:save $config "set nick \"*\"" "set nick \"$result\""]
  35. set result [string map [list {\[} \[ {\]} \] {\?} \? {\\} \\] $result]
  36. set nick [join $result]
  37. if {$error == "0"} {
  38. return 0
  39. }
  40. bind RAW - 432 check:validnickname
  41. return 1
  42. }
  43. realname {
  44. set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  45. set return [config:getinfo $config "set realname \"*\""]
  46. if {[string equal -nocase $return $result]} {
  47. return 2
  48. }
  49. set error [config:save $config "set realname \"*\"" "set realname \"$result\""]
  50. if {$error == "0"} {
  51. return 0
  52. }
  53. return 1
  54. }
  55. homechan {
  56. set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  57. set return [config:getinfo $tcl_config "set black(homechan) \"*\""]
  58. if {[string equal -nocase $return $result]} {
  59. return 2
  60. }
  61. set error [config:save $tcl_config "set black(homechan) \"*\"" "set black(homechan) \"$result\""]
  62. if {$error == "0"} {
  63. return 0
  64. }
  65. return 1
  66. }
  67. chanserv {
  68. set return [config:getinfo $tcl_config "set black(chanserv) \"*\""]
  69. if {[string equal -nocase $return $result]} {
  70. return 2
  71. }
  72. set error [config:save $tcl_config "set black(chanserv) \"*\"" "set black(chanserv) \"$result\""]
  73. if {$error == "0"} {
  74. return 0
  75. }
  76. return 1
  77. }
  78. hostchanserv {
  79. set return [config:getinfo $tcl_config "set black(hostchanserv) \"*\""]
  80. if {[string equal -nocase $return $result]} {
  81. return 2
  82. }
  83. set error [config:save $tcl_config "set black(hostchanserv) \"*\"" "set black(hostchanserv) \"$result\""]
  84. if {$error == "0"} {
  85. return 0
  86. }
  87. return 1
  88. }
  89. userlogin {
  90. set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  91. set return [config:getinfo $tcl_config "set black(username) \"*\""]
  92. if {[string equal -nocase $return $result]} {
  93. return 2
  94. }
  95. set error [config:save $tcl_config "set black(username) \"*\"" "set black(username) \"$result\""]
  96. if {$error == "0"} {
  97. return 0
  98. }
  99. return 1
  100. }
  101. userpass {
  102. set result [string map [list \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  103. set return [config:getinfo $tcl_config "set black(password) \"*\""]
  104. if {[string equal -nocase $return $result]} {
  105. return 2
  106. }
  107. set error [config:save $tcl_config "set black(password) \"*\"" "set black(password) \"$result\""]
  108. if {$error == "0"} {
  109. return 0
  110. }
  111. return 1
  112. }
  113. add-defaultmask {
  114. set return [config:getinfo $tcl_config "set black(hostadd) \"*\""]
  115. if {[string equal -nocase $return $result]} {
  116. return 2
  117. }
  118. set error [config:save $tcl_config "set black(hostadd) \"*\"" "set black(hostadd) \"$result\""]
  119. if {$error == "0"} {
  120. return 0
  121. }
  122. rehash
  123. return 1
  124. }
  125. broadcast-showtime {
  126. set return [config:getinfo $tcl_config "set black(bttime) \"*\""]
  127. if {[string equal -nocase $return $result]} {
  128. return 2
  129. }
  130. set error [config:save $tcl_config "set black(bttime) \"*\"" "set black(bttime) \"$result\""]
  131. if {$error == "0"} {
  132. return 0
  133. }
  134. rehash
  135. return 1
  136. if {[info exists black(broadcast:timer_start)]} {
  137. set scan_time [time_return_minute $result]
  138. set black(broadcast:timer_start) $scan_time
  139. }
  140. if {[info exists black(broadcast:counter)]} {
  141. set black(broadcast:counter) 0
  142. }
  143. }
  144. user-expire {
  145. set return [config:getinfo $tcl_config "set black(user_expire_time) \"*\""]
  146. if {[string equal -nocase $return $result]} {
  147. return 2
  148. }
  149. set error [config:save $tcl_config "set black(user_expire_time) \"*\"" "set black(user_expire_time) \"$result\""]
  150. if {$error == "0"} {
  151. return 0
  152. }
  153. rehash
  154. return 1
  155. }
  156. banmethod-expire {
  157. set return [config:getinfo $tcl_config "set black(banmethod_memory_time) \"*\""]
  158. if {[string equal -nocase $return $result]} {
  159. return 2
  160. }
  161. set error [config:save $tcl_config "set black(banmethod_memory_time) \"*\"" "set black(banmethod_memory_time) \"$result\""]
  162. if {$error == "0"} {
  163. return 0
  164. }
  165. if {[info exists black(banmethod_rem:timer_start)]} {
  166. set black(banmethod_rem:timer_start) [time_return_minute $result]
  167. }
  168. if {[info exists black(banmethod_rem:counter)]} {
  169. set black(banmethod_rem:counter) 0
  170. }
  171. rehash
  172. return 1
  173. }
  174. cmdchar {
  175. set return [config:getinfo $tcl_config "set black(cmdchar) \"*\""]
  176. if {[string equal -nocase $return $result]} {
  177. return 2
  178. }
  179. set error [config:save $tcl_config "set black(cmdchar) \"*\"" "set black(cmdchar) \"$result\""]
  180. if {$error == "0"} {
  181. return 0
  182. }
  183. rehash
  184. return 1
  185. }
  186. defaultlang {
  187. set return [config:getinfo $tcl_config "set black(default_lang) \"*\""]
  188. if {[string equal -nocase $return $result]} {
  189. return 2
  190. }
  191. set found_lang 0
  192. set get_lang_files [glob -directory "$black(dirname)/BlackTools/lang" "*lang.tcl"]
  193. foreach lang $get_lang_files {
  194. set split_lang [split $lang "."]
  195. set the_lang [lindex $split_lang 1]
  196. if {[string equal -nocase $result $the_lang]} {
  197. set found_lang 1
  198. }
  199. }
  200. if {$found_lang == 0} {
  201. blacktools:tell $unick $host $hand $chan $chan1 egg.5 "defaultlang $result"
  202. return
  203. }
  204. set error [config:save $tcl_config "set black(default_lang) \"*\"" "set black(default_lang) \"$result\""]
  205. if {$error == "0"} {
  206. return 0
  207. }
  208. rehash
  209. return 1
  210. }
  211. defaultoutput {
  212. set return [config:getinfo $tcl_config "set black(default_output) \"*\""]
  213. switch $return {
  214. 0 {
  215. if {[string equal -nocase $result "notice"]} {
  216. return 2
  217. }
  218. }
  219. 1 {
  220. if {[string equal -nocase $result "chan"]} {
  221. return 2
  222. }
  223. }
  224. 2 {
  225. if {[string equal -nocase $result "msg"]} {
  226. return 2
  227. }
  228. }
  229. }
  230. set error ""
  231. switch [string tolower $result] {
  232. notice {
  233. set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"0\""]
  234. }
  235. chan {
  236. set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"1\""]
  237. }
  238. msg {
  239. set error [config:save $tcl_config "set black(default_output) \"*\"" "set black(default_output) \"2\""]
  240. }
  241. default {
  242. return 0
  243. }
  244. }
  245. if {$error == "0"} {
  246. return 0
  247. }
  248. rehash
  249. return 1
  250. }
  251. floodmenuprot {
  252. set return [config:getinfo $tcl_config "set black(antiflood:cmd) \"*\""]
  253. if {[string equal -nocase $return $result]} {
  254. return 2
  255. }
  256. set error [config:save $tcl_config "set black(antiflood:cmd) \"*\"" "set black(antiflood:cmd) \"$result\""]
  257. if {$error == "0"} {
  258. return 0
  259. }
  260. return 1
  261. }
  262. userfloodmsgprot {
  263. set return [config:getinfo $tcl_config "set black(msg:flood) \"*\""]
  264. if {[string equal -nocase $return $result]} {
  265. return 2
  266. }
  267. set error [config:save $tcl_config "set black(msg:flood) \"*\"" "set black(msg:flood) \"$result\""]
  268. if {$error == "0"} {
  269. return 0
  270. }
  271. return 1
  272. }
  273. massfloodmsgprot {
  274. set return [config:getinfo $tcl_config "set black(mass:msg:flood) \"*\""]
  275. if {[string equal -nocase $return $result]} {
  276. return 2
  277. }
  278. set error [config:save $tcl_config "set black(mass:msg:flood) \"*\"" "set black(mass:msg:flood) \"$result\""]
  279. if {$error == "0"} {
  280. return 0
  281. }
  282. return 1
  283. }
  284. massfloodsilencetime {
  285. set return [config:getinfo $tcl_config "set black(mass:msg:silence_time) \"*\""]
  286. if {[string equal -nocase $return $result]} {
  287. return 2
  288. }
  289. set error [config:save $tcl_config "set black(mass:msg:silence_time) \"*\"" "set black(mass:msg:silence_time) \"$result\""]
  290. if {$error == "0"} {
  291. return 0
  292. }
  293. return 1
  294. }
  295. floodnotcprot {
  296. set return [config:getinfo $tcl_config "set black(notice:flood) \"*\""]
  297. if {[string equal -nocase $return $result]} {
  298. return 2
  299. }
  300. set error [config:save $tcl_config "set black(notice:flood) \"*\"" "set black(notice:flood) \"$result\""]
  301. if {$error == "0"} {
  302. return 0
  303. }
  304. return 1
  305. }
  306. pagelimit {
  307. set return [config:getinfo $tcl_config "set black(modul:nr:entries) \"*\""]
  308. if {[string equal -nocase $return $result]} {
  309. return 2
  310. }
  311. set error [config:save $tcl_config "set black(modul:nr:entries) \"*\"" "set black(modul:nr:entries) \"$result\""]
  312. if {$error == "0"} {
  313. return 0
  314. }
  315. return 1
  316. }
  317. away {
  318. set return [config:getinfo $tcl_config "set black(default_away) \"*\""]
  319. if {[string equal -nocase $return $result]} {
  320. return 2
  321. }
  322. set result [string map [list \" {\"} \[ {\[} \] {\]} \? {\?} \\ {\\}] $result]
  323. set error [config:save $tcl_config "set black(default_away) \"*\"" "set black(default_away) \"$result\""]
  324. if {$error == "0"} {
  325. return 0
  326. }
  327. set result [string map [list {\[} \[ {\]} \] {\?} \? {\\} \\] $result]
  328. putserv "AWAY :"
  329. putserv "AWAY :$result"
  330. return 1
  331. }
  332. antibotidle {
  333. set return [config:getinfo $tcl_config "set black(antibotidle_status) \"*\""]
  334. if {[string equal -nocase $return $result]} {
  335. return 2
  336. }
  337. if {![regexp {^[01]} $result]} {
  338. return 0
  339. }
  340. set error [config:save $tcl_config "set black(antibotidle_status) \"*\"" "set black(antibotidle_status) \"$result\""]
  341. if {$error == "0"} {
  342. return 0
  343. }
  344. rehash
  345. return 1
  346. }
  347. quote-usage {
  348. set return [config:getinfo $tcl_config "set black(quote:usage) \"*\""]
  349. if {[string equal -nocase $return $result]} {
  350. return 2
  351. }
  352. if {![regexp {^[01]} $result]} {
  353. return 0
  354. }
  355. set error [config:save $tcl_config "set black(quote:usage) \"*\"" "set black(quote:usage) \"$result\""]
  356. if {$error == "0"} {
  357. return 0
  358. }
  359. rehash
  360. return 1
  361. }
  362. chanremove-setting {
  363. set return [config:getinfo $tcl_config "set black(chanremove_all) \"*\""]
  364. if {[string equal -nocase $return $result]} {
  365. return 2
  366. }
  367. if {![regexp {^[01]} $result]} {
  368. return 0
  369. }
  370. set error [config:save $tcl_config "set black(chanremove_all) \"*\"" "set black(chanremove_all) \"$result\""]
  371. if {$error == "0"} {
  372. return 0
  373. }
  374. rehash
  375. return 1
  376. }
  377. add-mask {
  378. set return [config:getinfo $tcl_config "set black(hostdefaultadd) \"*\""]
  379. if {[string equal -nocase $return $result]} {
  380. return 2
  381. }
  382. if {![regexp {^[12345]} $result]} {
  383. return 0
  384. }
  385. set error [config:save $tcl_config "set black(hostdefaultadd) \"*\"" "set black(hostdefaultadd) \"$result\""]
  386. if {$error == "0"} {
  387. return 0
  388. }
  389. rehash
  390. return 1
  391. }
  392. }
  393. }
  394. ##############
  395. #########################################################################
  396. ## END ##
  397. #########################################################################