ZmEu

relay.tcl script for eggdrops!

Feb 28th, 2011
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.77 KB | None | 0 0
  1. ############ TCL relay script... for haqNET
  2. ## CONFIG
  3. # Fill the values as you want but don't forget to keep the same order between each array.
  4. # Remember that all is case sensitive, so don't write DuMmY if your eggdrop is named dummy :)
  5. set eggdrops {"eggy" "tracer" "eggydroid" "irssi"}
  6. set chans {"#Haqnet" "#traced"}
  7. set networks {"HAQNET" "freenode"}
  8. # Do you want to use bold (1), underline (2) or nothing (0) to highlight nicknames ?
  9. set high "0"
  10. # Do yo want to indicate from wich network comes the message (y/n)?
  11. set snet "n"
  12. # Do you want the bot transmit actions from the channel (y/n)?
  13. set transmit "y"; # default value is yes
  14. # Do you want the bot recept actions (y/n)?
  15. set receive "y"; # default value is yes
  16.  
  17. # transmission configuration
  18. set trans_pub "y"; # transmit the pub
  19. set trans_act "n"; # transmit the actions (/me)
  20. set trans_nick "n"; # transmit the nick changes
  21. set trans_join "n"; # transmit the join
  22. set trans_part "n"; # transmit the part
  23. set trans_quit "n"; # transmit the quit
  24. set trans_topic "n"; # transmit the topic changes
  25. set trans_kick "n"; # transmit the kicks
  26. set trans_mode "n"; #transmit the mode changes
  27.  
  28. # reception configuration
  29. set recv_pub "y"; # recept the pub
  30. set recv_act "n"; # recept the actions (/me)
  31. set recv_nick "n"; # recept the nick changes
  32. set recv_join "n"; # recept the join
  33. set recv_part "n"; # recept the part
  34. set recv_quit "n"; # recept the quit
  35. set recv_topic "n"; # recept the topic changes
  36. set recv_kick "n"; # recept the kicks
  37. set recv_mode "n"; #recept the mode changes
  38.  
  39. bind msg o|o "link.status" help:status
  40. bind msg - "link.help" help:cmds
  41.  
  42. if { $high == "1" } {
  43. set hlnick "\002"
  44. } elseif { $high == "2" } {
  45. set hlnick "\037"
  46. } else {
  47. set hlnick ""
  48. }
  49.  
  50. bind msg o|o "link.light" set:light
  51. bind msg o|o "link.net" set:snet
  52.  
  53. if { $transmit == "y" } {
  54. bind msg o|o "trans" set:trans
  55. if { $trans_pub == "y" } { bind pubm - * trans_pub }
  56. if { $trans_act == "n" } { bind ctcp - "ACTION" trans_act }
  57. if { $trans_nick == "n" } { bind nick - * trans_nick }
  58. if { $trans_join == "n" } { bind join - * trans_join }
  59. if { $trans_part == "n" } { bind part - * trans_part }
  60. if { $trans_quit == "n" } { bind sign - * trans_quit }
  61. if { $trans_topic == "n" } { bind topc - * trans_topic }
  62. if { $trans_kick == "n" } { bind kick - * trans_kick }
  63. if { $trans_mode == "n" } { bind mode - * trans_mode }
  64. }
  65.  
  66. if { $receive =="y" } {
  67. bind msg o|o "recv" set:recv
  68. if { $recv_pub == "y" } { bind bot - ">pub" recv_pub }
  69. if { $recv_act == "n" } { bind bot - ">act" recv_act }
  70. if { $recv_nick == "n" } { bind bot - ">nick" recv_nick }
  71. if { $recv_join == "n" } { bind bot - ">join" recv_join }
  72. if { $recv_part == "n" } { bind bot - ">part" recv_part }
  73. if { $recv_quit == "n" } { bind bot - ">quit" recv_quit }
  74. if { $recv_topic == "n" } { bind bot - ">topic" recv_topic }
  75. if { $recv_kick == "n" } { bind bot - ">kick" recv_kick }
  76. if { $recv_mode == "n" } { bind bot - ">mode" recv_mode }
  77. }
  78.  
  79. # proc setting the type of highlight
  80. proc set:light {nick host handle arg } {
  81. global hlnick
  82. if { $arg == "bo" } {
  83. set hlnick "\002"
  84. } elseif { $arg == "un" } {
  85. set hlnick "\037"
  86. } elseif { $arg == "off" } {
  87. set hlnick ""
  88. } else { putquick "NOTICE $nick :you must chose \002(bo)\002ld , \037(un)\037derline or (off)" }
  89. }
  90.  
  91. proc set:snet {nick host handle arg } {
  92. global snet
  93. if { $arg == "yes" } {
  94. set snet "y"
  95. } elseif { $arg == "no" } {
  96. set snet "n"
  97. } else { putquick "NOTICE $nick :you must chose yes or no" }
  98. }
  99.  
  100. # proc setting of transmission by msg
  101. proc set:trans { nick host handle arg } {
  102. global botnick transmit
  103. if { $transmit == "y" } {
  104. if { $arg == "" } {
  105. putquick "NOTICE $nick :you'd better try /msg $botnick trans help"
  106. }
  107. if { [lindex [split $arg] 0] == "help" } {
  108. putquick "NOTICE $nick :usage is /msg $botnick trans <value> on|off"
  109. putquick "NOTICE $nick :with <value> = pub, act, nick, join, part, quit, topic, kick, mode"
  110. return 0
  111. } else {
  112. set proc_change "trans_[lindex [split $arg] 0]"
  113. switch [lindex [split $arg] 0] {
  114. "pub" { set type pubm }
  115. "act" { set type ctcp }
  116. "nick" { set type nick }
  117. "join" { set type join }
  118. "part" { set type part }
  119. "quit" { set type sign }
  120. "topic" { set type topc }
  121. "kick" { set type kick }
  122. "mode" { set type mode }
  123. }
  124. if { [lindex [split $arg] 1] == "on" } {
  125. bind $type - * $proc_change
  126. } elseif { [lindex [split $arg] 1] == "off" } {
  127. unbind $type - * $proc_change
  128. } else {
  129. putquick "NOTICE $nick :[lindex [split $arg] 1] is not a correct value, choose \002on\002 or \002off\002"
  130. }
  131. }
  132. } else {
  133. putquick "NOTICE $nick :transmission is not activated, you can't change anything"
  134. }
  135. }
  136.  
  137. # proc setting of reception by msg
  138. proc set:recv { nick host handle arg } {
  139. global botnick receive
  140. if { $receive == "y" } {
  141. if { $arg == "" } {
  142. putquick "NOTICE $nick :you'd better try /msg $botnick recv help"
  143. }
  144. if { [lindex [split $arg] 0] == "help" } {
  145. putquick "NOTICE $nick :usage is /msg $botnick recv <value> on|off"
  146. putquick "NOTICE $nick :with <value> = pubm, act, nick, join, part, quit, topic, kick, mode"
  147. return 0
  148. } else {
  149. set change ">[lindex [split $arg] 0]"
  150. set proc_change "recv_[lindex [split $arg] 0]"
  151. if { [lindex [split $arg] 1] == "on" } {
  152. bind bot - $change $proc_change
  153. } elseif { [lindex [split $arg] 1] == "off" } {
  154. unbind bot - $change $proc_change
  155. } else {
  156. putquick "NOTICE $nick :[lindex [split $arg] 1] is not a correct value, choose \002on\002 or \002off\002"
  157. }
  158. }
  159. } else {
  160. putquick "NOTICE $nick :reception is not activated, you can't change anything"
  161. }
  162. }
  163.  
  164. # proc used by all others for transmission
  165. proc trans_bot { usercmd chan usernick text } {
  166. global eggdrops chans botnick
  167. set transmsg [concat $usercmd $usernick $text]
  168. set me [lsearch $eggdrops $botnick]
  169. if {$chan == [lindex $chans $me]} {
  170. putallbots $transmsg
  171. } else {
  172. return 0
  173. }
  174. }
  175.  
  176. # proc transmission of pub (trans_pubm = y)
  177. proc trans_pub {nick uhost hand chan text} {
  178. trans_bot ">pub" $chan $nick $text
  179. }
  180.  
  181. # proc transmission of action (trans_act = y)
  182. proc trans_act {nick uhost hand chan key text} {
  183. set arg [concat $key $text]
  184. trans_bot ">act" $chan $nick $arg
  185. }
  186.  
  187. # proc transmission of nick changement
  188. proc trans_nick {nick uhost hand chan newnick} {
  189. trans_bot ">nick" $chan $nick $newnick
  190. }
  191.  
  192. # proc transmission of join
  193. proc trans_join {nick uhost hand chan} {
  194. trans_bot ">join" $chan $chan $nick\($uhost\)
  195. }
  196.  
  197. # proc transmission of part
  198. proc trans_part {nick uhost hand chan text} {
  199. set arg [concat $chan $text]
  200. trans_bot ">part" $chan $nick $arg
  201. }
  202.  
  203. # proc transmission of quit
  204. proc trans_quit {nick host hand chan text} {
  205. trans_bot ">quit" $chan $nick $text
  206. }
  207.  
  208. # proc transmission of topic changement
  209. proc trans_topic {nick uhost hand chan topic} {
  210. set arg [concat $chan $topic]
  211. trans_bot ">topic" $chan $nick $arg
  212. }
  213.  
  214. # proc transmission of kick
  215. proc trans_kick {nick uhost hand chan victim reason} {
  216. set arg [concat $victim $chan $reason]
  217. trans_bot ">kick" $chan $nick $arg
  218. }
  219.  
  220. # proc transmission of mode changement
  221. proc trans_mode {nick uhost hand chan mc {victim ""}} {
  222. if {$victim != ""} {append mc " $victim" }
  223. set text [concat $nick $chan $mc]
  224. trans_bot ">mode" $chan $nick $text
  225. }
  226.  
  227. # proc reception of pub
  228. proc recv_pub {frm_bot command arg} {
  229. global eggdrops chans hlnick botnick snet networks
  230. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  231. set me [lsearch $eggdrops $botnick]
  232. set recvchan [lindex $chans $me]
  233. set speaker [make_user [lindex [split $arg] 0] $him]
  234. putquick "PRIVMSG $recvchan :$speaker> [lrange $arg 1 end]"
  235. } else {
  236. return 0
  237. }
  238. }
  239.  
  240. # proc reception of action
  241. proc recv_act {frm_bot command arg} {
  242. global eggdrops chans hlnick botnick snet networks
  243. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  244. set me [lsearch $eggdrops $botnick]
  245. set recvchan [lindex $chans $me]
  246. set speaker [make_user [lindex [split $arg] 0] $him]
  247. putquick "PRIVMSG $recvchan :* $speaker [lrange $arg 2 end]"
  248. } else {
  249. return 0
  250. }
  251. }
  252.  
  253. # proc reception of nick changement
  254. proc recv_nick {frm_bot command arg} {
  255. global eggdrops chans hlnick botnick snet networks
  256. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  257. set me [lsearch $eggdrops $botnick]
  258. set recvchan [lindex $chans $me]
  259. set speaker [make_user [lindex [split $arg] 0] $him]
  260. putquick "PRIVMSG $recvchan :*** $speaker is now known as [lrange $arg 1 end]"
  261. } else {
  262. return 0
  263. }
  264. }
  265.  
  266. # proc reception of join
  267. proc recv_join {frm_bot command arg} {
  268. global eggdrops chans hlnick botnick snet networks
  269. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  270. set me [lsearch $eggdrops $botnick]
  271. set recvchan [lindex $chans $me]
  272. set speaker [make_user [lindex [split $arg] 1] $him]
  273. putquick "PRIVMSG $recvchan :--> $speaker has joined channel [lindex [split $arg] 0]"
  274. } else {
  275. return 0
  276. }
  277. }
  278.  
  279. # proc reception of part
  280. proc recv_part {frm_bot command arg} {
  281. global eggdrops chans hlnick botnick snet networks
  282. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  283. set me [lsearch $eggdrops $botnick]
  284. set recvchan [lindex $chans $me]
  285. set speaker [make_user [lindex [split $arg] 0] $him]
  286. putquick "PRIVMSG $recvchan :<-- $speaker has left channel [lindex [split $arg] 1] ([lrange $arg 2 end])"
  287. } else {
  288. return 0
  289. }
  290. }
  291.  
  292. # proc reception of quit
  293. proc recv_quit {frm_bot command arg} {
  294. global eggdrops chans hlnick botnick snet networks
  295. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  296. set me [lsearch $eggdrops $botnick]
  297. set recvchan [lindex $chans $me]
  298. set speaker [make_user [lindex [split $arg] 0] $him]
  299. putquick "PRIVMSG $recvchan :-//- $speaker has quit ([lrange $arg 1 end])"
  300. } else {
  301. return 0
  302. }
  303. }
  304.  
  305. # proc reception of topic changement
  306. proc recv_topic {frm_bot command arg} {
  307. global eggdrops chans hlnick botnick snet networks
  308. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  309. set me [lsearch $eggdrops $botnick]
  310. set recvchan [lindex $chans $me]
  311. set speaker [make_user [lindex [split $arg] 0] $him]
  312. putquick "PRIVMSG $recvchan :*** $speaker changes topic of [lindex [split $arg] 1] to '[lrange $arg 2 end]'"
  313. } else {
  314. return 0
  315. }
  316. }
  317.  
  318. # proc reception of kick
  319. proc recv_kick {frm_bot command arg} {
  320. global eggdrops chans hlnick botnick snet networks
  321. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  322. set me [lsearch $eggdrops $botnick]
  323. set recvchan [lindex $chans $me]
  324. set speaker [make_user [lindex [split $arg] 1] $him]
  325. putquick "PRIVMSG $recvchan :*** $speaker has been kicked from [lindex [split $arg] 2] by [lindex [split $arg] 0]: [lrange $arg 3 end]"
  326. } else {
  327. return 0
  328. }
  329. }
  330.  
  331. # proc reception of mode changement
  332. proc recv_mode {frm_bot command arg} {
  333. global eggdrops chans hlnick botnick snet networks
  334. if {[set him [lsearch $eggdrops $frm_bot]] >= 0} {
  335. set me [lsearch $eggdrops $botnick]
  336. set recvchan [lindex $chans $me]
  337. set speaker [make_user [lindex [split $arg] 1] $him]
  338. putquick "PRIVMSG $recvchan :*** $speaker set mode [lrange $arg 2 end]"
  339. } else {
  340. return 0
  341. }
  342. }
  343.  
  344. proc make_user { unick thenb } {
  345. global snet networks hlnick
  346. if { $snet == "y" } {
  347. set speaker [concat "$hlnick$unick (from [lindex $networks $thenb])$hlnick"]
  348. } else {
  349. set speaker $hlnick$unick$hlnick
  350. }
  351. return $speaker
  352. }
  353.  
  354. # proc status
  355. proc help:status { nick host handle arg } {
  356. global trans_pub trans_act trans_nick trans_join trans_part trans_quit trans_topic trans_kick trans_mode recv_pub recv_act recv_nick recv_join recv_part recv_quit recv_topic recv_kick recv_mode hlnick transmit receive chan1 chan2
  357. putquick "PRIVMSG $nick :\002 Global status\002"
  358. putquick "PRIVMSG $nick :\037type\037 -- | trans -|- recept |"
  359. putquick "PRIVMSG $nick :global -- | -- $transmit -- | -- $receive -- |"
  360. putquick "PRIVMSG $nick :pub -- | -- $trans_pub -- | -- $recv_pub -- |"
  361. putquick "PRIVMSG $nick :act -- | -- $trans_act -- | -- $recv_act -- |"
  362. putquick "PRIVMSG $nick :nick -- | -- $trans_nick -- | -- $recv_nick -- |"
  363. putquick "PRIVMSG $nick :join -- | -- $trans_join -- | -- $recv_join -- |"
  364. putquick "PRIVMSG $nick :part -- | -- $trans_part -- | -- $recv_part -- |"
  365. putquick "PRIVMSG $nick :quit -- | -- $trans_quit -- | -- $recv_quit -- |"
  366. putquick "PRIVMSG $nick :topic -- | -- $trans_topic -- | -- $recv_topic -- |"
  367. putquick "PRIVMSG $nick :kick -- | -- $trans_kick -- | -- $recv_kick -- |"
  368. putquick "PRIVMSG $nick :mode -- | -- $trans_mode -- | -- $recv_mode -- |"
  369. putquick "PRIVMSG $nick :nicks appears as $hlnick$nick$hlnick"
  370. putquick "PRIVMSG $nick :[lindex $chan1 0] is on [lindex $chan1 1] and transmit to [lindex $chan1 2]"
  371. putquick "PRIVMSG $nick :[lindex $chan2 0] is on [lindex $chan2 1] and transmit to [lindex $chan2 2]"
  372. putquick "PRIVMSG $nick :\002 END of STATUS"
  373. }
  374.  
  375. # proc help
  376. proc help:cmds { nick host handle arg } {
  377. global botnick
  378. putquick "NOTICE $nick :/msg $botnick trans <type> on|off to change the transmissions"
  379. putquick "NOTICE $nick :/msg $botnick recv <type> on|off ti change the receptions"
  380. putquick "NOTICE $nick :/msg $botnick link.status to see my actual status"
  381. putquick "NOTICE $nick :/msg $botnick link.help for this help"
  382. putquick "NOTICE $nick :/msg $botnick link.light <bo|un|off> to bold, underline or no highlight"
  383. putquick "NOTICE $nick :/msg $botnick link.net <yes|no> to show the network"
  384. }
  385.  
  386. putlog "Chan Link 2.1 loaded"
Add Comment
Please, Sign In to add comment