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 

exemp script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
AlbozZz
Voice


Joined: 26 Jan 2020
Posts: 3

PostPosted: Sun Mar 08, 2020 12:44 pm    Post subject: exemp script Reply with quote

Now the script is work great, but need to change the commands and remove channel name, when i add IP in exemp.txt file list,

someone can help here, how to change this public comand , thx in advance

!exemp help change in !help

!exemp list change in !list

!exemp del 1 change in !del 75.34.37.12 | 75.34.37.* | 75.34.*

!exemp add change in !add 75.34.37.12 | 75.34.37.* | 75.34.*

and to remove the name channel when i add Ip on exemp.txt list
to add only the IP


Code:


proc check_ip {ip} {
   set file [open "exemp.txt" r]
   set fdata [split [read $file] \n]
   close $file
   foreach entry $fdata {
      if {[string match $entry $ip]} {
         return 1
      }
   }
   return 0
}

bind pub n|n !exemp  exemp:cmd

set exemp(file) "exemp.txt"

if {![file exists $exemp(file)]} {
   set file [open $exemp(file) w]
   close $file
}

proc exemp:cmd {nick host hand chan arg} {
   global exemp
   
   set arg0 [lindex [split $arg] 0]
   set arg1 [lindex [split $arg] 1]
if {$arg0 == ""} {
   putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
   return
}
switch $arg0 {
   add {
if {$arg1 == ""} {
   putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
   return
}
   set file [open $exemp(file) a]
   puts $file "$chan $arg1"
   close $file
   putserv "NOTICE $nick :EXEMP I added\002 $arg1 \002in my ExempList."
   }

   list {
   set file [open $exemp(file) "r"]
   set read [read -nonewline $file]
   close $file
   set data [split $read "\n"]
   set i 0
if {$data == ""} {
   putserv "NOTICE $nick :EXEMP There are\002 no IP \002added to ExempList."
   return
}
   putserv "NOTICE $nick :EXEMP The list of IP added in my ExempList."
foreach line $data {
   set read_chan [lindex [split $line] 0]
if {[string match -nocase $read_chan $chan]} {
   set i [expr $i +1]
   set read_blackchan [lindex [split $line] 1]
   putserv "NOTICE $nick :$i.) $read_blackchan"
         }
      }
   }

   
   del {
   array set exempdel [list]
if {![regexp {.*?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*?\((.*?)\)} $arg1]} {
   putserv "NOTICE $nick :EXEMP Use: \002!exemp help\002 for more informations."
   return
}


set file [open $exemp(file) "r"]
   set data [read -nonewline $file]
   close $file
   set lines [split $data "\n"]
   set counter -1
   set line_counter -1
   set current_place -1
foreach line $lines {
   set line_counter [expr $line_counter + 1]
   set read_chan [lindex [split $line] 0]
if {[string match -nocase $read_chan $chan]} {
   set counter [expr $counter + 1]
   set exempdel($counter) $line_counter
   }
}

foreach place [array names exempdel] {
   if {$place == [expr $arg1 - 1]} {
   set current_place $exempdel($place)
   }
}

if {$current_place == "-1"} {
   putserv "NOTICE $nick :EXEMP The entry number\002 $arg1 \002does not exist."   
   return   
}

   set delete [lreplace $lines $current_place $current_place]
   set files [open $exemp(file) "w"]
   puts $files [join $delete "\n"]
   close $files
   set file [open $exemp(file) "r"]
   set data [read -nonewline $file]
   close $file
if {$data == ""} {
   set files [open $exemp(file) "w"]
   close $files
}
   putserv "NOTICE $nick :EXEMP The entry number\002 $arg1 \002was removed from ExempList."

   }

   help {
   putserv "NOTICE $nick :EXEMP You can add IP using: \002!exemp add <IP>\002 "
   putserv "NOTICE $nick :EXEMP To see all the IP in ExempList use:\002 !exemp list\002"
   putserv "NOTICE $nick :EXEMP To delete a IP use:\002 !exemp del <number>\002 (from the ExempList)"
      }
   }
}


this is how works the script for now.

Code:


<+BoB> !exemp add 75.34.37.12
 -TestBot- EXEMP I added 75.34.37.12 in my ExempList.

 <+BoB> !exemp list
 -TestBot- EXEMP The list of IP added in my ExempList.
 -TestBot- 1.) 75.34.37.12

<BoB> !exemp del 1
 -TestBot- EXEMP The entry number 1 was removed from ExempList.

<BoB> !exemp list
-TestBot- EXEMP There are no  IP added to ExempList.

<+BoB> !exemp del 75.34.37.12
 -TestBot- EXEMP Use: !exemp help for more informations.

 <+BoB> !exemp help
 -TestBot- EXEMP You can add IP using: !exemp add <IP>
 -TestBot- EXEMP To see all the IP in ExempList use: !exemp list
 -TestBot- EXEMP To delete a IP use: !exemp del <number> (from the ExempList)



This is the way how is adding now the ip on exemp.txt wrong :
need to remove the channel and to be only on #opers chan to use the all commands !list !help !add !del

Code:


#Test 75.34.37.12



the right way to add every IP in exemp.txt without name channel only the IP like this:

Code:


75.34.37.12
75.34.37.*
75.34.*

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 -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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