This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

auto join / part channel with random time

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

auto join / part channel with random time

Post by Repdientu »

I wrote this piece of code, but it's not working correctly. I hope you can help me

Code: Select all

set channelToJoin "#chatvn"

set quoteList {
    "Sự thành công không phải là chìa khóa của sự hạnh phúc. Sự hạnh phúc là chìa khóa của sự thành công. Nếu bạn yêu những gì bạn đang làm, bạn sẽ thành công."
    "Cách duy nhất để làm việc tốt là yêu những gì bạn đang làm."
    "Không có bí mật để thành công. Đó là sự chuẩn bị, công việc chăm chỉ và học hỏi từ thất bại."
    ...
    # Danh sách câu danh ngôn tiếp theo...
}

proc autoPartJoinChannel {} {
    set randomJoinTime [expr {int(rand() * 180) + 120}] ;
    set randomPartTime [expr {int(rand() * 180) + 120}] ;
    
    channel add $::channelToJoin
    set afterId [after [expr {$randomJoinTime * 1000}] "channel remove $::channelToJoin"]
    after [expr {($randomJoinTime + $randomPartTime) * 1000}] "channel add $::channelToJoin"
    
    set randomQuoteIndex [expr {int(rand() * [llength $::quoteList])}]
    set randomQuote [lindex $::quoteList $randomQuoteIndex]
    after [expr {int(rand() * ($randomPartTime - $randomJoinTime)) * 1000}] {
        putquick "PRIVMSG $::channelToJoin :$randomQuote"
    }
}


bind join - * {
    after 1000 autoPartJoinChannel
}

in party line
[21:40] <Mina> [14:40:17] Tcl error [
[21:40] <Mina> after 1000 autoPartJoinChannel

and in irc eggdrop not join again

[21:42] * Mina (Mina@vps-880306e4.vps.ovh.ca) has joined #ChatVN
[21:46] * Mina (Mina@vps-880306e4.vps.ovh.ca) has left #ChatVN
[21:55] <!Repdientu> .
User avatar
CrazyCat
Revered One
Posts: 1217
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

A bind must call a procedure, not sure you can make an anonymous one.

Code: Select all

bind join - * ujoin
proc ujoin {nick uhost handle chan} {
   after 1000 autoPartJoinChannel 
}
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

thank you, it worked
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

i have updated as above but the time of eggdrop join and part is not correct according to random install time. Looking forward to all the helpers

Code: Select all

# Kênh để Eggdrop tự động tham gia
set channelToJoin "#chatvn"

# Hàm thực hiện tự động rời khỏi và tham gia kênh khi kết nối thành công
bind join - * ujoin
proc ujoin {nick uhost handle chan} {
   after 1000 autoPartJoinChannel
}

# Danh sách các câu danh ngôn


# Hàm xử lý tự động rời khỏi và tham gia kênh
proc autoPartJoinChannel {} {
    set randomJoinTime [expr {int(rand() * 580) + 180}] ;# Thời gian ngẫu nhiên từ 2 đến 5 phút (120 đến 300 giây)
    after [expr {$randomJoinTime * 1000}] {
        channel remove $::channelToJoin
		autoJoinChannel
	}
}

proc autoJoinChannel {} {
	set randomPartTime [expr {int(rand() * 580) + 180}] ;# Thời gian ngẫu nhiên từ 2 đến 5 phút (120 đến 300 giây)
	after [expr {$randomPartTime * 1000}] {
		channel add $::channelToJoin
		delaypartchannel
    }
}
proc delaypartchannel {} {
	set nextRandomTime [expr {int(rand() * 480) + 120}] ;# Thời gian ngẫu nhiên từ 2 đến 8 phút (120 đến 600 giây)
	after [expr {$nextRandomJoinTime * 1000}] autoPartJoinChannel
}

Code: Select all

[09:03] * xavang (xavang@xxx) has joined #ChatVN
[09:03] * xavang (xavang@xxx) has left #ChatVN
Post Reply