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
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

All my scripts related to network services, such as ChanServ, Nickserv.. etc are mainly for use on DALnet, as I myself use DALnet. :mrgreen:

./awyeah @ DALnet
·­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 »

Anyway ... back to Sergios problem.
It continuous have the problem.
when i do
/msg eirhnh !chanserv sop #parea list
and i open the file i see this part

Code: Select all

 
-ChanServ Access List Records- 
accesslist.txt contains just that one line of text.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
S
Sergios
Voice
Posts: 14
Joined: Fri Jul 23, 2004 2:48 pm

Post by Sergios »

Did it work?Mine doesnt. I know that it must say

Code: Select all

-ChanServ Access List Records- 
but after that it must say and the list. Me too, it say that message and 2 blank lines. :-?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Okay tell you what, Alchera use this.
Since DALnet has a dffierent output of channel access lists, like:
-ChanServ- SOp list for #user
-ChanServ- 1 - Abort (abort@jhb-152-101.tm.net.my)
-ChanServ- 2 - Debora (jaysee@202.158.58.228)
-ChanServ- 3 - FrEe-sTyLe (~FreE-StYL@208.155.67.177)
-ChanServ- 4 - Kevmart (kevmart@noIRC.org)
-ChanServ- 5 - MiRiNdA (mirinda@mirinda.nu)
-ChanServ- 6 - Point (pointzero@pix142166196119.nbtel.net)
-ChanServ- End of list.

So then, we can modify our code, accordingly to:

Code: Select all

#Set the filename to save the access list records in. 
set accesslist "accesslist.txt" 

if {![file exists $accesslist]} { 
 putlog "ACCESS LIST FILE:\002 $accesslist \002file \002does not exist\002, *creating file*: \002$accesslist\002" 
 set file [open $accesslist "w"] 
 puts $file "-ChanServ Access List Records-\n" 
 close $file 
} 

bind msgm n !chanserv get:access:list 
bind notc - save:access:list 

proc get:access:list {nick uhost hand text} { 
 set type [lindex $text 0]; set chan [lindex $text 1] 
 if {([string equal -nocase "list" [lindex $text 2]])} { 
 putquick "PRIVMSG chanserv :$type $chan list" 
 } 
} 

proc save:access:list {nick uhost hand text {dest ""}} { 
 global botnick accesslist 
  if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} {
  if{(([string match "*/[0-9]/*" [lindex $text 0]]) && ([string match "*(*@*)*" [lindex $text 2]])) || ([string match "*list for #*" $text]) || ([string match "*End of List*" $text])} { 
   if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file } 
    set file [open $accesslist "a"]; puts $file $text; close $file; return 0
    } 
  } 
}
DALnet's access list doesn't show the (added by: bla bla at 0:00pm) stuff.
So then we dont need to get that matched. For DALnet I would suggest use matching "(*@*)".
Last edited by awyeah on Fri Jul 30, 2004 6:59 am, edited 2 times in total.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

For Sergios:

If you have quit upon everything use this.
But this will record every notice sent to the bot by ChanServ.
This should definately work! :mrgreen:

Code: Select all

#Set the filename to save the access list records in. 
set accesslist "accesslist.txt" 

if {![file exists $accesslist]} { 
 putlog "ACCESS LIST FILE:\002 $accesslist \002file \002does not exist\002, *creating file*: \002$accesslist\002" 
 set file [open $accesslist "w"] 
 puts $file "-ChanServ Access List Records-\n" 
 close $file 
} 

bind msgm n !chanserv get:access:list 
bind notc - save:access:list 

proc get:access:list {nick uhost hand text} { 
 set type [lindex $text 0]; set chan [lindex $text 1] 
 if {([string equal -nocase "list" [lindex $text 2]])} { 
 putquick "PRIVMSG chanserv :$type $chan list" 
 } 
} 

proc save:access:list {nick uhost hand text {dest ""}} { 
 global botnick accesslist 
  if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} {
  if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file }
    set file [open $accesslist "a"]; puts $file $text; close $file; return 0
    } 
  } 
} 
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
S
Sergios
Voice
Posts: 14
Joined: Fri Jul 23, 2004 2:48 pm

Post by Sergios »

I test it but the result was the same. I remove one } cause it crash the bot. Well, nevermind. It dont want to work. I have change and the services to see if the notice of chanserv have something wrong. Thanks for reply all of you,and lets continue programming others tcls :D
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Oki... much playing etc awyeah and the result does not change, it just does nothing but write one line of text to a file.

So, as an experiment I started from scratch which does get a result of sorts ie. the AOp/SOp list this time is received by the bot which was not happening with your code. The following test code is far far from complete, or working 100%. It does, however, manage to write the first line of text received from ChanServ when the command is triggered (in this case via public command). The problem is having all that is received written to the file and I am sure this is an array "thingie" which is going straight over my head at this point in time.

Anyway, here's the code.

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"

# Create the storage file for the access list.
if {![file exists $accesslist]} {
 set acc_fd [open $accesslist w]
 close $acc_fd
 unset acc_fd
 if {![file exists $accesslist]} {
  putloglev c  "*** (notes) ERROR: Unable to write to $accesslist ***"
  return 0
 }
}

bind pub n test access:list
bind notc - "* list for *" write:list

proc write:list {nick host hand arg {dest ""}} {
  set msg [ctrl:filter $arg]
  if {[string equal $dest $::botnick]} {
    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 {[string match $type "aop"]} {
    putserv "PRIVMSG $::chanserv :aop $chan list"
  } else {
    putserv "PRIVMSG $::chanserv :sop $chan list"
  }
  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 
}
Any assistance to get this working properly will be greatly appreciated. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
S
Sergios
Voice
Posts: 14
Joined: Fri Jul 23, 2004 2:48 pm

Post by Sergios »

Ok, i will test it. Thanks for the reply.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You will have todo a string match. As I already did alchera.

Code: Select all

bind notc - "*list for*" << is good
How about:

Code: Select all

bind notc - "*(*@*)*" << ???
The output is like:
-ChanServ- 1 - awyeah (awyeah@dal.net)
-ChanServ- 2 - Alchera (Alchera@forum.egghelp.org)
[1] Second index is a number. ===> match "*/[0-9/]*"
[2] Third index is an nick. ===> match "*/[A-Z/]* (bec a nick cannot consist of numbers only, so theres gotta be some alphabets or chars!)
[3] Fourth index is an (ident@ip.address). ===> match "(*@*)"

Then we can match them to the $text, or even to each list index, like [lindex $text number]. But matching it with the lindex is far better!

Logically something like this should definately work.
So we will have to match these in some/all sort of way.

As for the DALnet one which I tried to make earler I matched the wrong indexes. Try this, errr:

index 0 = -
index 1 = number(s)
index 2 = nick
index 3 = ident@ip.address

Code: Select all

proc save:access:list {nick uhost hand text {dest ""}} { 
 global botnick accesslist 
  if {([string equal -nocase $botnick $dest]) && ([string equal $nick "ChanServ"])} { 
  if{((string equal "-" [lindex $text 0]]) && ([string match "*/[0-9]/*" [lindex $text 1]]) && ([string match "*(*@*)*" [lindex $text 3]])) || ([string match -nocase "*list for*" $text]) || ([string match -nocase "*end of list*" $text])} { 
   if {![file exists $accesslist]} { set file [open $accesslist "w"]; puts $file "-ChanServ Access List Records-\n"; close $file } 
    set file [open $accesslist "a"]; puts $file $text; close $file; return 0 
    } 
  } 
} 
Last edited by awyeah on Thu Jul 29, 2004 1:43 am, edited 2 times in total.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

If you want to write every notice which is sent by ChanServ.

*** BIND ***
[1] Bind to notc without any matching. (bind notc - "*" procedure:here)

*** PROCEDURE ***
[2] Check if the destination is the bots nick.
[3] Check if the nick which is noticing is only ChanServ.
[4] Do not match any text.
[5] Just open the file, write to it and close it.


This should do it.
As I mentioned earlier, it would write any notice it receives.

Earlier, I released a script 'ChanServ Verbose Logging Script' something on egghelp.org's TCL Archive. Basically it catches all channel verbose notices sent, and writes them to a file (Also records /chanserv why of the person doing the access list modification). You can take a look at that, from which you can get an idea or help regarding this.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Well, nevermind. It dont want to work. I have change and the services to see if the notice of chanserv have something wrong. Thanks for reply all of you,and lets continue programming others tcls.
Try and try.....untill you succeed.
Even it's daddy will work, just wait n see. :wink:
I haven't logged onto IRC since a few days so I'm not testing anything I paste over here, its just what comes in my mind and I write it down. :mrgreen:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
S
Sergios
Voice
Posts: 14
Joined: Fri Jul 23, 2004 2:48 pm

Post by Sergios »

Ok guys, thanks for the help and the replies, i will set it manually cause if it writes every notice from chanserv we will have a problem. I have a question, i want a script to delete all the lines from accesslist.txt. I have read the FAQ but i want to erase all the lines, not the file. Thanks
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

One easy thing is to delete the file itself, and then make an empty one.
Deleting all the lines could be a messy job... on the other hand.

Code: Select all

#To delete the old file
exec rm $myfile

#To make/open a new file
set deletefile [open $myfile "w"]

#To close and save the file just made
close $deletefile
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

awyeah wrote:exec rm
Why do you keep doing that? Use 'file delete' to delete files.
Have you ever read "The Manual"?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Sorry, I wasn't aware of that command, heh. ;)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked