SHOW:
|
|
- or go back to the newest paste.
1 | #Music Is Knowledge | |
2 | #La base du code appartient à quote.tcl | |
3 | #Quote Script by Steinsky. Version: 1.2.1 | |
4 | #See www.cotch.net, irc.fwaggle.net, irc.zone.dk and virus.eleethal.com | |
5 | #Merci donc à lui | |
6 | ||
7 | # Ici on précise le chemin du fichier texte | |
8 | set zikfile /mon/repertoire/music.txt | |
9 | ||
10 | # 0 = résultat en privmsg | |
11 | # 1 = résultat en notice | |
12 | set zikvianotice 0 | |
13 | ||
14 | # Ici on précise le ou les channels où le bot répondra | |
15 | set zikchannel "#Chan1" | |
16 | ||
17 | if { ![info exists toolbox_loaded] } { source scripts/alltools.tcl } | |
18 | ||
19 | bind pub - !read read:pub:read | |
20 | ||
21 | proc read:pub:read {nick uhost hand channel arg} { | |
22 | global zikfile zikvianotice | |
23 | if { [string tolower $channel] ne [string tolower $::zikchannel] } { return 0; } | |
24 | if { [llength [split $arg]] == 0 } { | |
25 | putserv "NOTICE $nick :Merci de préciser ta recherche" | |
26 | return 0 | |
27 | } | |
28 | set ziks "" | |
29 | if { [file exists $zikfile] } { set file [open $zikfile r] | |
30 | } else { | |
31 | if { $zikvianotice == 0 } { putmsg $channel "$zikfile n'existe pas." } | |
32 | if { $zikvianotice == 1 } { putnotc $nick "$zikfile n'existe pas." } | |
33 | return 0 | |
34 | } | |
35 | while { ![eof $file] } { | |
36 | set zik [gets $file] | |
37 | if { $zik != "" } { | |
38 | set ziks [linsert $ziks end $zik] | |
39 | } | |
40 | } | |
41 | close $file | |
42 | if { $arg != "" } { | |
43 | set pattern [string tolower $arg] | |
44 | set aziks "" | |
45 | set zik "" | |
46 | foreach zik $ziks { | |
47 | set lowzik [string tolower $zik] | |
48 | if { [string match $pattern $lowzik] } { | |
49 | set aziks [linsert $aziks end $zik] | |
50 | } | |
51 | set ziks "" | |
52 | set ziks $aziks | |
53 | } | |
54 | } | |
55 | set row [rand [llength $ziks]] | |
56 | if { [expr $row >= 0] && [expr $row < [llength $ziks]] } { | |
57 | set zik [lindex $ziks $row] | |
58 | } | |
59 | if { $zik != "" } { | |
60 | if { $zikvianotice == 0 } { | |
61 | putmsg $zikchannel "Morceau: $zik" | |
62 | } | |
63 | if { $zikvianotice == 1 } { | |
64 | putnotc $nick "$zik" | |
65 | } | |
66 | } | |
67 | return 1 | |
68 | } | |
69 | ||
70 | ||
71 | putlog "Zik.tcl By KiBa Loaded" |