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 

!add !del true and black IP (transformed from mrc to tcl)

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
AdmiraL
Voice


Joined: 21 Feb 2021
Posts: 11
Location: Germany

PostPosted: Sun Feb 21, 2021 5:31 pm    Post subject: !add !del true and black IP (transformed from mrc to tcl) Reply with quote

Hello all..

I need a little help from everyone ..

With this code under, example if I do in my channel #egitim !addto 1.1.1.1 or !addto 1.1.* And then bot automatically makes the IP in this file blacklist.txt

Code:

on *:TEXT:!addto *:#egitim:{
  if ($nick ison #) && ($2 = $read(blacklist.txt,w,$2)) && ($2) { msg #egitim 47I can't add this IP 4IP:  $+ $2 $+  47because is in the List! | halt }
  if ($nick ison #) && ($2 != $read(blacklist.txt,s,$2)) && ($2) { write blacklist.txt $2 | msg #egitim 4IP:  $+ $2 $+  47I have add in List! | kline *@ $+ $2 5m | halt }
}


If i want a ip delete, and when i do !delto 1.1.1.1 and the bot can automatically delete this IP from blacklist.txt
Code:

on *:TEXT:!delto *:#egitim:{
  if ($nick ison #) && ($2 != $read(blacklist.txt,s,$2)) && ($2) { //filter -ffcx blacklist.txt blacklist.txt $2 | msg #egitim 4IP:  $+ $2 $+  47I have deleted from the List! | kline -*@ $+ $2 | halt }
}
}

and last code when I do trueip 1.1.1.1 and bot automatically puts this ip in list allow.txt! if this IP is in list, bot says * Nick 1 or 2 IP are in my list! * and if there is no IP in this list allow.txt then automatically writes in this channel #egitim! add 1.1.1.1
Code:

ON *:TEXT:*trueip*:#egitim: {
  var %f = allow.txt

  if (!$file(%f)) { msg $chan ( $+ $nick $+ ): Error, file $qt(%f) does NOT exists or it is empty! | return }

  if ($window(@temp)) { window -c $v1 }

  window -hj1000000000 @temp
  loadbuf @temp $qt(%f)

  var %t = $line(@temp,0)
  var %i = 1

  while (%i <= %t) {
    var %w = $strip($line(@temp,%i))

    if (!%w) { goto next }

    if (%w iswm $2) || (%w == $2) { var %tot = $addtok(%tot,%w,32) }

    :next
    inc %i
  }

  window -c @temp

  if (%tot) { msg $chan ( $+ $nick $+ ): $numtok(%tot,32) Matches: %tot }
  else { msg $chan ( $+ $nick $+ ): No results founded! | /msg #egitim !add $2 }
}

thank you if someone has time, i would be grateful.

AdmiraL
Back to top
View user's profile Send private message Visit poster's website
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1032
Location: France

PostPosted: Mon Mar 29, 2021 9:43 am    Post subject: Reply with quote

This code is not tested, but it may answer to your demands for blacklist.
It could seem complicated but it's just because I tried to make modules in it.

But globaly, I don't understand why you use a blacklist system when klines are for 5 minutes, and there is no system to rekill if an user which has IP in the file is coming.

Code:
set ipchan #raspfr
set ipdbfile databases/iplist.db

bind pub - !addto ip:add
bind pub - !delto ip:del

set iplist {}

proc ip:add {nick uhost handle chan text} {
   if {[string tolower $chan] ne [string tolower $::ipchan]} {
      putserv "PRIVMSG $nick :You're not on the good channel"
      return
   }
   set ip [join [lindex [split $text] 0]]
   if {[ip:infile $ip] == 1} {
      putserv "PRIVMSG $::ipchan :$ip is already in database"
      return
   }
   ip:fin $ip
}

proc ip:del {nick uhost handle chan text} {
   if {[string tolower $chan] ne [string tolower $::ipchan]} {
      putserv "PRIVMSG $nick :You're not on the good channel"
      return
   }
   set ip [join [lindex [split $text] 0]]
   if {![ip:infile $ip] == 1} {
      putserv "PRIVMSG $::ipchan :$ip is not in database"
      return
   }
   ip:fout $ip
}

proc ip:infile {ip} {
   if {[llength $::iplist] == 0 && [file exists $::iplist]} {
      set fi [open $::ipdbfile "r"]
      set ::iplist [split [read -nonewline $fi] "\n"]
      close $fi
   }
   if {[lsearch $::iplist $ip]==-1} {
      return 0
   } else {
      return 1
   }
}

proc ip:fin {ip} {
   lappend ::iplist $ip
   set fo [open $::ipdbfile "w"]
   foreach cip $::iplist {
      puts $fo $cip
   }
   close $fo
   putserv "kline *@$ip 5m :halt"
}

proc ip:fout {ip} {
   set pos [lsearch $::iplist $ip]
   set ::iplist [lreplace $::iplist $pos $pos]
   set fo [open $::ipdbfile "w"]
   foreach cip $::iplist {
      puts $fo $cip
   }
   close $fo
   putserv "kline -*@$ip"
}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
AdmiraL
Voice


Joined: 21 Feb 2021
Posts: 11
Location: Germany

PostPosted: Mon Mar 29, 2021 4:19 pm    Post subject: Reply with quote

CrazyCat wrote:
This code is not tested, but it may answer to your demands for blacklist.
It could seem complicated but it's just because I tried to make modules in it.

But globaly, I don't understand why you use a blacklist system when klines are for 5 minutes, and there is no system to rekill if an user which has IP in the file is coming.



Thanks a lot, u r the best u have make perfect the first and second.

now only one code is missing, the third one.

i think the third one is like badwords

when i have a ip 10.10.10.* in this list allow.txt and i make for example trueip 10.10.10.9 or trueip 10.10.10.14 detected automatic and says this IP its in my allow list.


Code:
ON *:TEXT:*trueip*:#egitim: {
  var %f = allow.txt

  if (!$file(%f)) { msg $chan ( $+ $nick $+ ): Error, file $qt(%f) does NOT exists or it is empty! | return }

  if ($window(@temp)) { window -c $v1 }

  window -hj1000000000 @temp
  loadbuf @temp $qt(%f)

  var %t = $line(@temp,0)
  var %i = 1

  while (%i <= %t) {
    var %w = $strip($line(@temp,%i))

    if (!%w) { goto next }

    if (%w iswm $2) || (%w == $2) { var %tot = $addtok(%tot,%w,32) }

    :next
    inc %i
  }

  window -c @temp

  if (%tot) { msg $chan ( $+ $nick $+ ): $numtok(%tot,32) Matches: %tot }
  else { msg $chan ( $+ $nick $+ ): No results founded! | /msg #egitim !add $2 }
}


EXAMPLE i have make a test and u can see.. give Kline!

* 21:40:32 * Shooter trueip 109.201.137.45
* 21:40:33 * @AdmiraL (Shooter): No results founded!
* 21:40:33 * @AdmiraL !addto 109.201.137.45
* 21:40:34 * K:Line added for *@109.201.137.45 on Mon Mar 29 19:40:33 2021 GMT (from Radio!Radio@NetAdmin


when its in allow list than says: make nothing because ip is allow list

* 20:44:11 * Shooter trueip 217.138.194.75
* 20:44:11 * @AdmiraL (Shooter): 1 Matches: 217.138.194.*
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests 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