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.

Trying to create a sop/vop/aop/akick list

Help for those learning Tcl or writing their own scripts.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Sergios: Be patient, there will be a script that will do as you wish and will work as you wish and will only respond to a specific message from ChanServ "soonish". :)

awyeah was indicating that it could be used for other ChanServ notices as well, by simply changing what to look for in the bind.

One item I had missed early on was the fact that the first line of a ChanServ notice contains bold text. If that isn't filtered then basically nothing works.

In the code I wrote for testing I replaced "putquick" with "putserv". Using "putquick" ends up with ChanServ (DALnet) sending this >> "-ChanServ- Error! "/msg ChanServ" is no longer supported. Use "/msg chanserv@services.dal.net" or "/chanserv" instead."

I shall now go and do battle :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Stripping the codes is a good idea.
I've only seen ChanServ put it in bold in the first line
'-ChanServ- SOp list for #awyeah'.

After that, I know all nicks, and ip addresses listed of
the access list are in plain text format without any control codes.
However there might be one, at the end as well '-ChanServ- End of list'.


Alchera use, any:

Code: Select all

putquick "PRIVMSG chanserv@services.dal.net :AOP $chan list" -next
putquick "PRIVMSG chanserv@services.dal.net :AOP $chan list"
putserv "PRIVMSG chanserv@services.dal.net :AOP $chan list"
But specify, 'chanserv@services.dal.net' not simply 'chanserv'
DALnet has enfocred this because:

Services impersonators use similar nicks to ChanServ, like:
ChanSev, ChannelServ, ChanService, ChanServices, ChanServer etc.
to fool people into getting their passwords. So just by simply: /msg chanserv <bla bla> (wont make chanserv get your command)

On DALnet you will need to specify: /chanserv@services.dal.net.
As the part after the @ is like the uhost. So even if an impersonator uses a nick, and a user mistakenly sends a notice to:

E.g: /msg ChanService@services.dal.net (the msg will not go as a nick with that uhost would cease to exist, if the nick ChanService is online)
That is why they came up with this thing.

So for everyone I suggest you use: /msg chanserv@services.dal.net bla bla
Another alteration can be: /chanserv bla bla

For that, on mIRC like I use: /chanserv aop #chan list
In, tcl if it works it can be something like: (Only for DALnet!)

Code: Select all

putserv "chanserv aop $chan list"
or
putserv "chanserv :aop $chan list"

#I am not sure but one of these will work. I think the one without the ":".
#You can use the same with putquick, puthelp etc.
Everyone, who reads this post... please be aware this is only for DALnet's ChanServ as I am not aware with ChanServ services of other IRC networks.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

awyeah:
How about:

Code: Select all

bind notc - "*(*@*)*" << ???
Just brilliant :D
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Ok ... Here's what I have. It works! :)

Code: Select all

# File name of the storage file for the access list.
set accesslist "accesslist.txt"

# Full name of channel services
set chanserv "chanserv@Services.dal.net"

bind pub n list access:list
bind notc - "*(*@*)*" write:list

proc write:list {nick host hand arg {dest ""}} {
  if {([string equal $dest $::botnick]) && ([string equal $nick "ChanServ"])} {
    # Create the storage file for the access list.
    if {![file exists $::accesslist]} {
     set acc_fd [open $::accesslist w]
     puts $acc_fd "-ChanServ Access List Records-\n"
     close $acc_fd
    }
    set acc_fd [open $::accesslist a]
    puts $acc_fd $arg
    close $acc_fd
  }
}

proc access:list {nick uhost hand chan text} {
  set type [string tolower $text]
  if {[string match $type "aop"] || [string match $type "sop"]} {
    # Remove old storage file
    if {[file exists $::accesslist]} {file delete $::accesslist}
    putserv "PRIVMSG $::chanserv :$type $chan list"
  } else {
    return
  }
}
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Btw, you also might want to bind to the starting and the ending notices. :lol:

Code: Select all

bind notc - "*list for #*" write:list
bind notc - "*End of list*" write:list
This should complete it! yay :mrgreen:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Ooooo .. I never thought of trying that idea. I am, however, aware of stackable notices and that idea of yours awyeah has given me another idea. LOL

The ability to have the access list files named for each channel ie accesslist.channel.txt (I hope). :D

Sergios: Theroretically, what I have done so far (in my last post) will work on your network. You just simply change "set chanserv" to what you use to access your channel services.

The script is triggered via public command in main ie "list aop" or "list sop". To have it list HOp & VOp as well, just change this

Code: Select all

if {[string match $type "aop"] || [string match $type "sop"]} {
to this

Code: Select all

if {[string match $type "aop"] || [string match $type "sop"] || [string match $type "hop"] || [string match $type "vop"]} {
Re DALnet services access: I know of only one other network that has a similar setup ie /msg ChanService@services.dal.net
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Why do you do an match when you should compare them if are equal?!
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

or just use regexp to make it abit smaller :)

Code: Select all

if {[regexp {(sop|aop|vop|hop)} $type]} {
Elen sila lúmenn' omentielvo
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

I'm all in favour of small and the famous KISS (Keep It Simple Stupid) principle.

Thank you gentlemen :D
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Here's the finished (?) code.

Code: Select all

# Name of the storage file for the access list.
set accesslist "accesslist.txt"

# Full name of channel services
set chanserv "chanserv@Services.dal.net"

#################
# BIND commands #
#################
bind pub n list access:list
bind notc - "* list for *" write:list
bind notc - "*(*@*)*" write:list
bind notc - "*End of list.*" write:list

proc write:list {nick host hand arg {dest ""}} {
  set msg [ctrl:filter $arg]
  if {([string equal $dest $::botnick]) && ([string equal $nick "ChanServ"])} {
    # Create the storage file for the access list.
    set acc_fd [open $::accesslist a]
    puts $acc_fd $msg
    close $acc_fd
  }
}

proc access:list {nick uhost hand chan text} {
  set type [string tolower $text]
  if {[regexp {(sop|aop)} $type]} {
    # Remove old storage file
    if {[file exists $::accesslist]} {file delete $::accesslist}
    putserv "PRIVMSG $::chanserv :$type $chan list"
  } else {
    return
  }
}

# ctrl:filter <string> 
# Strip all control characters. Thanks to Ppslim.

proc ctrl:filter {str} { 
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str 
  return $str 
}
Here's the contents of the file.
SOp list for #ballarat
1 - almozo (Almozo@mctn1-8053.nb.aliant.net)
2 - Ricochet (~ricochet@82-37-208-102.cable.ubr06.dudl.blueyonder.co.uk)
End of list.
Sergios: You may need to delete this line of code

Code: Select all

bind notc - "*End of list.*" write:list
And you need to change

Code: Select all

if {[regexp {(sop|aop)} $type]} {
To

Code: Select all

if {[regexp {(sop|aop|hop|vop)} $type]} {
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Actualy the ctrl:filter is from ppslim :mrgreen:

[string equal $dest $::botnick] <~ [isbotnick $dest]? also, use string equal -nocase if you want to make it compare it nocase (lower and upper chars and so on)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Capital 'p' now lower case 'p' :D

I keep forgetting about this one. LOL

Code: Select all

[isbotnick $dest]
Thanks again caesar. :)

Senatus Populusque Romanus
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Code: Select all

# Name of the storage file for the access list. 
set accesslist "accesslist.txt"

# Full name of channel services.
set chanserv "chanserv@Services.dal.net"

#################
# BIND commands #
#################
bind pub n list access:list
bind notc - "* list for *" write:list
bind notc - "*(*@*)*" write:list
bind notc - "*End of list.*" write:list

proc write:list {nick host hand arg {dest ""}} {
  set msg [ctrl:filter $arg]
  if {([isbotnick $dest]) && ([string equal $nick "ChanServ"])} {
    # Create the storage file for appending.
    set acc_fd [open $::accesslist a]
    puts $acc_fd $msg
    close $acc_fd
  }
}

proc access:list {nick uhost hand chan text} {
  set type [string tolower $text]
  if {[regexp {(sop|aop)} $type]} {
    # Remove old storage file
    if {[file exists $::accesslist]} {file delete $::accesslist}
    putserv "PRIVMSG $::chanserv :$type $chan list"
  } else {
    return
  }
}

# ctrl:filter <string> 
# Strip all control characters. Thanks to ppslim.

proc ctrl:filter {str} { 
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str 
  return $str 
}
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Okay... after 42 posts, we have finally sovled this tiny issue.
Delayed... but relevant :mrgreen: :wink:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

A learning curve for moi :D

What's the bet Sergios doesn't even use it? LOL
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Locked