|
Joined: Aug 2003
Posts: 66
Babel fish
|
OP
Babel fish
Joined: Aug 2003
Posts: 66 |
Is there an If then else for using the favorites (channels) in a script?
Thanks
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
using a @window just to do something with the info,
alias chanlist {
var %listcount = $ini(mirc.ini,chanfolder,0) - 1
var %i = 0
window -ls @FavoriteChannels 200 50 200 200
while (%i <= %listcount) {
var %x = n $+ %i
.aline @FavoriteChannels $gettok($readini(mirc.ini,chanfolder,%x),1,44)
inc %i
}
}
not sure what you want to do with the data, but that is a teaser to show you where it is and how to get at it. EDIT: It is important to remember that in the help files it clearly states that you shouldn't make changes to ini ifles that mIRC uses. While you can pull the info out and use the data in a script, you should give serious consideration to modifying any file that mIRC uses.
Last edited by MikeChat; 18/01/06 06:31 AM.
|
|
|
|
Joined: Aug 2003
Posts: 66
Babel fish
|
OP
Babel fish
Joined: Aug 2003
Posts: 66 |
Thanks for that info. Here is what I'm attempting to do ... I have a bot that I want to part channels if its left alone in them unless the channel is in the favorites list. Then I want the bot to stay in the channel.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
Not Fully Tested, but here is some starting
alias favchan dialog -m favchan favchan
dialog favchan {
title "Channel Anchor for Bot"
size -1 -1 245 95
option dbu
list 100, 5 15 150 81, sort
edit "", 200, 160 40 80 10
button "Delete Selected", 900, 160 15 80 10
button "Add Channel", 901, 160 55 80 10
button "Save and Close", 999, 160 75 80 15, cancel
}
on *:dialog:favchan:init:0:{
loadbuf -o favchan 100 favchan.txt
}
on *:dialog:favchan:sclick:900:{ did -d favchan 100 $did(favchan,100).sel }
on *:dialog:favchan:sclick:901:{ did -a favchan 100 $did(favchan,200).text | did -r favchan 200 }
on *:dialog:favchan:sclick:999:{ savebuf -o favchan 100 favchan.txt }
on *:part:#:{ .timerfavchan 1 1 favchancheck $chan }
alias favchancheck {
echo -s . $nick($$1,0)
var %chancount = $nick($$1,0)
if (%chancount <= 1) {
var %checkchan = $read(favchan.txt,w,$+(*,$1,*))
if (%checkchan == $null) { part $1 }
}
}
on *:quit:{
var %chanlistc = $comchan($me,0)
var %i = 1
while (%i <= %chanlistc) {
var %chanlist = %chanlist $+ $chr(44) $+ $comchan($nick,%i)
inc %i
}
.timerquitter 1 1 quitlist %chanlist
}
alias quitlist {
var %chanlist = $$1
var %count = $gettok(%chanlist,0,44)
var %i = 1
while (%i <= %count) {
favchancheck $gettok(%chanlist,%i,44)
inc %i
}
}
; Added below to populate the listbox of the dialog the first time.
alias chanlist {
var %listcount = $ini(mirc.ini,chanfolder,0) - 1
var %i = 0
while (%i <= %listcount) {
var %x = n $+ %i
did -a favchan 100 $gettok($readini(mirc.ini,chanfolder,%x),1,44)
inc %i
}
}
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Not sure why Mike wrote up such a long code. The following should work just fine on !*:part:#:{
alone $chan
}
alias alone {
if ($nick($1,0) == 1) && !$readini(mirc.ini,chanfolder,$1) {
.part $1
}
}
on !*:kick:#:{
alone $chan
}
on !*:quit:{
var %a = 1, %b = $comchan($me,0)
while %a <= %b {
alone $comchan($me,%a)
inc %a
}
}
If you need an explanation of the code, ask and I'll do my best to provide one.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
Your code failed, understandably. I have repaired it.
on !*:part:#:{
.timerchanbot 1 1 alone $chan
}
alias alone {
if ($nick($1,0) == 1) && !$readini(mirc.ini,chanfolder,$1) {
part $1
}
}
on !*:kick:#:{
.timerchanbot 1 1 alone $chan
}
on !*:quit:{
var %a = 1, %b = $comchan($me,0)
while (%a <= %b) {
.timerchanbot $+ %a 1 1 alone $comchan($me,%a)
inc %a
}
}
1) Russel's code didnt allow mIRC to update the channel list, I have added timers to give mIRC time to update, which fixes this. 2) My code included a dialog interface to allow you to manage the channels the bot would stay in when the bot was the only nick in channel using a text file. This allows you to include or remove channels without writing to mIRC.ini. 3) Use whatever you wish, I don't see any problem with either except that to use the mIRC.ini is less flexible than to use my method. 4) If you really have a lot lot of channels to manage then the text file is much too slow, and really if you are using the mIRC bot as a channel service bot on your net you should consider getting a services addon for that IRCd.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
further testing revealed the alone alias isn't working correctly alias alone { if ($nick($1,0) == 1) && !$readini(mirc.ini,chanfolder,$1) { .part $1 } } the ini format for mIRC is n + a number n0 n1 n2 so on This replacement for the "alone" alias works as expected
alias alone {
var %chan = $$1
var %listcount = $ini(mirc.ini,chanfolder,0) - 1
var %i = 0
while (%i <= %listcount) {
var %x = n $+ %i
var %chanlist = %chanlist $gettok($readini(mirc.ini,chanfolder,%x),1,44)
inc %i
}
if (%chan !isin %chanlist) && ($nick($1,0) == 1) { part %chan }
}
|
|
|
|
|