egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vip Script Based on Hosts ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
paps
Voice


Joined: 24 May 2007
Posts: 5

PostPosted: Thu May 24, 2007 4:39 pm    Post subject: Vip Script Based on Hosts ? Reply with quote

Hello

I'm looking for a very simple script. It should voice anyone who joins a specified channel if their host matches one in a text file.

Google doesnt give me anything.

Thx in advance
Back to top
View user's profile Send private message
xU
Voice


Joined: 24 May 2007
Posts: 7

PostPosted: Thu May 24, 2007 5:02 pm    Post subject: Reply with quote

hi paps,

you can use script without read from file:

Code:
## set(s) ##
############

## channels
set chanvoice "#xU #qadsia"


## host voice
ser hosts {
"*@*.qualitynet.net"
"*xU@*.WeArab.Knights"
"*@qadsia.com"
}

## bind ##
##########

bind join - * proc:join

## proc ##
##########
proc proc:join { nick host hand chan } {
global chanvoice hosts
if {([isbotnick $nick]) || (![botisop $chan]) || (![lsearch -exact [string tolower $chanvoice] [string tolower $chan]] == "-1")} {return 0}
foreach hostv $hosts {
if {([string match -nocase "$hostv" $host])} {putquick "mode $chan +v $nick;break}
}
}
Back to top
View user's profile Send private message MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu May 24, 2007 6:48 pm    Post subject: Reply with quote

Add these hosts to a specific handle and give it the +v flag. Set your channel to +autovoice and they'll be autovoiced on join.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
paps
Voice


Joined: 24 May 2007
Posts: 5

PostPosted: Fri May 25, 2007 9:16 am    Post subject: Reply with quote

Thanks xU and Sir_Fz. It will help me a lot Very Happy

And now what about a script that voices only people that are authed on Quakenet with a certain account ?
The bot should voice anyone that is authed (Q account) with one of the account-name listed on a text file or something...

Is this possible ? (My bot is on quakenet)

Thanks :]
Back to top
View user's profile Send private message
xU
Voice


Joined: 24 May 2007
Posts: 7

PostPosted: Fri May 25, 2007 11:33 am    Post subject: Reply with quote

## set(s) ##
############

## channels
set chanvoice "#xU #qadsia"


## filename
set filehost "hosts.txl"

## bind ##
##########

bind join - * proc:join

## proc ##
##########
proc proc:join { nick host hand chan } {
global chanvoice txtfile
if {([isbotnick $nick]) || (![botisop $chan]) || (![lsearch -exact [string tolower $chanvoice] [string tolower $chan]] == "-1")} {return 0}
set ropen [open $filehost r]
foreach hostv $ropen {
if {([string match -nocase "$hostv" $host])} {putquick "mode $chan +v $nick;break}
}
Back to top
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 25, 2007 12:18 pm    Post subject: Reply with quote

@xU:
What good would using a foreach-loop on a filehandle do?
Were'nt you thinking of actually reading the content of the file?
Also, you forget to close it afterwards, leaving uneccesary filehandles open...
Furthermore, your braces {} are unbalanced, and using lsearch on a plain string is not advisable (actually, in some rare conditions it's really bad).

edit:
Might aswell include a piece of code that is working:
Assumes one hostmask per line within the voice.txt file

Code:
set voicefile "voice.txt"
setudef flag filevoice
bind join - * join:checkvoice
proc join:checkvoice {nick host hand chan} {
 if {[channel get $chan chanvoice] && ![isbotnick $nick] && [botisop $chan]} {
  set _t [split [read [set fid [open $::voicefile "RDONLY"]]] "\n"]
  close $fid
  foreach h $_t {
   if {[string match -nocase $h $host]} {
    pushmode $chan +v $nick
    return
   }
  }
 }
}

_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Fri May 25, 2007 12:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
paps
Voice


Joined: 24 May 2007
Posts: 5

PostPosted: Fri May 25, 2007 12:26 pm    Post subject: Reply with quote

thx xU, but as far as i can see your script is based on hosts, right ? I'd like a script that voices based on the "Authed as Account-Name" (which appears on the /whois of Quakenet).
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 25, 2007 12:32 pm    Post subject: Reply with quote

@paps:
As I am not familiar with Quakenet, which respose-code would be used to indicate the Q auth from a whois reply?
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
paps
Voice


Joined: 24 May 2007
Posts: 5

PostPosted: Fri May 25, 2007 1:02 pm    Post subject: Reply with quote

Well, I dont think i really understand the question, but:

When you type /whois nick on quakenet you get something like this if the guy is authed :
Quote:
nick is xxxx@xxxx.users.quakenet.org * Real Name
nick on +#channel #channel2 @#channel3
nick using port80b.se.quakenet.org Located at Port80, Sweden
nick is authed as xxxx
nick End of /WHOIS list.


When you do a /whois on someone that is not authed, this is what you get :
Quote:
nick is ~xxxxx@xxx-xx-xxx-x-xxx.xxx.host.net * Real Name
nick on #channel
nick using *.quakenet.org QuakeNet IRC Server
nick End of /WHOIS list.


Is this enough to make a script work ?

thx
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 25, 2007 1:30 pm    Post subject: Reply with quote

I'll try to explain my query alittle better then;
Each response-line from a whois-query (such as the examples you posted) is preceeded with a numeric responsecode (three digits). These are used to allow the client to know what kind of information the server is sending.

Taking the second example you posted, what is actually sent from the server is this:
Quote:
311 nick ~xxxxx@xxx-xx-xxx-x-xxx.xxx.host.net * :Real Name
319 nick :#channel
312 nick *.quakenet.org :QuakeNet IRC Server
318 nick :End of /WHOIS list.

What we need is the number for the "nick is authed as xxxx" line. Unfortunately, this is not a "rfc 1459" message, but a QuakeNet feature (yes, some other networks use it aswell, I know...)

Also worth noting, implementing this would require your bot to send a whois-query whenever someone joins the channel. On highly trafficed channels this might cause some performace degradations.. just so you know.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri May 25, 2007 2:01 pm    Post subject: Reply with quote

You can use a /who reply for this (raw 354 reply)
Code:
set chanvoice(channel) "#channel"
set chanvoice(file) "chanvoice.txt"

proc chanvoice:join {nick host hand chan} {
  global chanvoice
  if {![string equal -nocase $chanvoice(channel) $chan]} { return }
  puthelp "WHO $nick n%a"
}

proc chanvoice:raw {from raw arg} {
  global chanvoice
  set nick [lindex [split $arg] 1]
  set auth [lindex [split $arg] 2]
  if {$auth == "" || $auth == "0"} { return }
  set data [read -nonewline [set file [open "$chanvoice(file)" r]]]
  close $file
  foreach x [split $data \n] {
    if {$x == ""} { return }
    if {[string equal -nocase $auth $x]} {
        pushmode $chanvoice(channel) +v $nick
        break
    }
  }
}


Not tested, but can be used as a basebone...
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 25, 2007 2:36 pm    Post subject: Reply with quote

Interresting, I suppose this could be extended to create a database of auth'd nicks (and their accuntname) by extending the WHO-query to the speciffic channel when the bot joins.
Should also be trivial to modify the raw 354 "handler" to update a list of nick/auths-pairs to cache this information in order to further reduce traffic.

Might almost be worth writing a module..

Edit:
Just found this page that provided some nice information: http://www.mircscripts.org/showdoc.php?type=tutorial&id=2412
Might be a good idea to tag the query in case any other scripts would use these extended /WHO-queries.
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Fri May 25, 2007 2:45 pm    Post subject: Reply with quote

the t option can be added.

A fixed version with the t paramater:

Code:
set chanvoice(channel) "#channel"
set chanvoice(file) "chanvoice.txt"

proc chanvoice:join {nick host hand chan} {
  global chanvoice
  if {![string equal -nocase $chanvoice(channel) $chan]} { return }
  puthelp "WHO $nick n%at,88"
}

proc chanvoice:raw {from raw arg} {
  global chanvoice
  set tag [lindex [split $arg] 1]
  if {$tag != "88"} { return }
  set nick [lindex [split $arg] 2]
  set auth [lindex [split $arg] 2#3]
  if {$auth == "" || $auth == "0"} { return }
  set data [read -nonewline [set file [open "$chanvoice(file)" r]]]
  close $file
  foreach x [split $data \n] {
    if {$x == ""} { return }
    if {[string equal -nocase $auth $x]} {
        pushmode $chanvoice(channel) +v $nick
        break
    }
  }
}


The tag in this example is 88.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Fri May 25, 2007 2:47 pm    Post subject: Reply with quote

You'd still need some bindings I suppose... and [lindex ... 2#3] ? :p
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
paps
Voice


Joined: 24 May 2007
Posts: 5

PostPosted: Fri May 25, 2007 2:53 pm    Post subject: Reply with quote

So, what would be the bindings ?

I dont understand anything in TCL Sad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber