Tekil Mesaj gösterimi
Alt 13 Şubat 2008, 18:32   #3
Çevrimdışı
SaW
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Yanıt: Geveze Tcl (Konuşan bot)




Kodları açık görebildiğimiz için kendi adıma teşekkür ederim BuCaLi : )
Böylece olumlu/olumsuz eleştrilerimizi daha sağlıklı sunabiliriz bundan da herkes kazançlı çıkar sanırım..

Programlamada bir kural vardır; tek satır bile fazla kod gereksizdir ve bütün koda kötü demeye yeterlidir.. Çünkü yazılan her yazıda bot dosyayı baştan sonra okuyor ve her satır için fazladan işlem yapmış oluyor.. O yüzden sonuca gidebilecek en kısa yoldan gitmek her zaman daha iyidir..

Kod:   Kodu kopyalamak için üzerine çift tıklayın!
proc konus { nick uhost host chan arg } { global botnick if {[string match -nocase "*selam*" "$arg"] || [string match -nocase "*slm*" "$arg"]} { yaz "selam.txt" $chan $nick } if {[string match -nocase "*te?ekk*" "$arg"]} { yaz "tşk.txt" $chan $nick } if {[string match -nocase "*tel*" "$arg"]} { yaz "telefon.txt" $chan $nick } if {[string match -nocase "*iyi*" "$arg"] || [string match -nocase "ii*" "$arg"]} { yaz "iyi.txt" $chan $nick } if {[string match -nocase "*nbr*" "$arg"] || [string match -nocase "*naber*" "$arg"] || [string match -nocase "*nas?ls?n*" "$arg"]} { yaz "nasılsın.txt" $chan $nick } if {[string match -nocase "*nrd*" "$arg"] || [string match -nocase "*nerden*" "$arg"]} { yaz "nerden.txt" $chan $nick } if {[string match -nocase "*canım*" "$arg"] || [string match -nocase "*aşkım*" "$arg"]} { yaz "aşkım.txt" $chan $nick } if {[string match -nocase "*alo*" "$arg"]} { yaz "alo.txt" $chan $nick } if {[string match -nocase "*or*damısın*" "$arg"]} { yaz "ordamısın.txt" $chan $nick } if {[string match -nocase "*of*" "$arg"]} { yaz "off.txt" $chan $nick } if {[string match -nocase "*bay*" "$arg"] || [string match -nocase "*bye*" "$arg"]} { yaz "bye.txt" $chan $nick } if {[string match -nocase "*hyr*" "$arg"] || [string match -nocase "*hay?r*" "$arg"]} { yaz "hayır.txt" $chan $nick } if {[string match -nocase "*neden*" "$arg"] || [string match -nocase "*ni?in*" "$arg"] || [string match -nocase "*niye*" "$arg"]} { yaz "neden.txt" $chan $nick } if {[string match -nocase "*yaş*" "$arg"] || [string match -nocase "*asl*" "$arg"]} { yaz "asl.txt" $chan $nick } if {[string match -nocase "*bot*" "$arg"]} { yaz "bot.txt" $chan $nick } if {[string match -nocase "haha*" "$arg"] || [string match -nocase "hehe*" "$arg"] || [string match -nocase "*muha*" "$arg"] || [string match -nocase "*zuhah*" "$arg"] || [string match -nocase "*pohah*" "$arg"]} { yaz "komik.txt" $chan $nick } if {[string match -nocase "ee*" "$arg"]} { yaz "eee.txt" $chan $nick } if {[string match -nocase "ok" "$arg"] || [string match -nocase "oke" "$arg"] || [string match -nocase "*tamam*" "$arg"]} { yaz "tamam.txt" $chan $nick } if {[string match -nocase "*merhaba*" "$arg"] || [string match -nocase "*mrb*" "$arg"]} { yaz "merhaba.txt" $chan $nick } if {[string match -nocase "*olmaz*" "$arg"]} { yaz "olmaz.txt" $chan $nick } if {[string match -nocase "*evlen*" "$arg"]} { yaz "evlenelim.txt" $chan $nick } if {[string match -nocase "*gelim*" "$arg"]} { yaz "gelim.txt" $chan $nick } if {[string match -nocase "*gidicem*" "$arg"] || [string match -nocase "*gidiyom*" "$arg"] || [string match -nocase "*gidiyorum*" "$arg"]} { yaz "gidicem.txt" $chan $nick } if {[string match -nocase "*gelmicem*" "$arg"]} { yaz "gelmem.txt" $chan $nick } if {[string match -nocase "*geldim*" "$arg"] || [string match -nocase "*or*dayım*" "$arg"]} { yaz "geldim.txt" $chan $nick } if {[string match -nocase "*sıkıldım*" "$arg"]} { yaz "sıkıldım.txt" $chan $nick } if {[string match -nocase "cevap*" "$arg"]} { yaz "cevap.txt" $chan $nick } if {[string match -nocase "*bilmem*" "$arg"]} { yaz "bilmem.txt" $chan $nick } if {[string match -nocase "*peki*" "$arg"]} { yaz "peki.txt" $chan $nick } if {[string match -nocase "*olabilir*" "$arg"]} { yaz "olabilir.txt" $chan $nick } }

Buradan başlayalım..
oradaki her kelimeyi daha öncesinde bir değişken içerisine setlemek ve o değişkendeki verileri proc içerisinde bir döngü içerisinde taratıp tek if ile olayı çözebilirdin.. örnek olarak:



Kod:   Kodu kopyalamak için üzerine çift tıklayın!
set kelimeler "selam kelam melam vs" proc {nick uhost host chan arg} { global kelimeler foreach a $kelimeler { if {[string match -nocase *$a* $arg]} { yaz "$a.txt" $chan $nick } } }

Bu sadece genel mantığını göstermek için bir örnekti daha düzgün birşey çıkabilir ortaya tabiki..
Bir diğeri ise:

Kod:   Kodu kopyalamak için üzerine çift tıklayın!
utimer 1[list putserv "privmsg $chan $rmsg"]

Satırı.. Buradaki timer'ın mantığını anlamış değilim.. Eğer putserv'ı bir saniye daha geç iletmekse maksat, putserv yerine puthelp kullanıp timer kullanmaya gerek görmeyebilirdin, dediğim gibi fazladan işlem herzaman gereksizdir..

Onun haricinde emeğine sağlık ve çalışmalarında başarılar diliyorum.

 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları reklam ver Benimmekan Mobil Sohbet