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.

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

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
AdmiraL
Voice
Posts: 15
Joined: Sun Feb 21, 2021 4:55 pm
Location: Germany
Contact:

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

Post by AdmiraL »

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: Select all

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: Select all

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: Select all

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
User avatar
CrazyCat
Revered One
Posts: 1304
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

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: Select all

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"
}
User avatar
AdmiraL
Voice
Posts: 15
Joined: Sun Feb 21, 2021 4:55 pm
Location: Germany
Contact:

Post by AdmiraL »

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: Select all

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.*
Post Reply