mIRC Home    About    Download    Register    News    Help

Print Thread
How to kick with older reason? Help me pls #268791 29/04/21 02:21 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
I use the illustrative example to make it easy for you to imagine and understand as follows:
1. When Op type the command:! B <Nickname here> then Bot will automatically banned and kicked that Nickname with radom reason.txt.
For example:
<@Robert>! B petra
* MyBot sets mode: + b *!*@01.11.21.22
* petra was kicked from #myroom by MyBot (Bye! You are not welcome here [id: 12345])

(The reason kick "Bye! You are not welcome here" was in reasonkick.txt and the [id: %knum], [id: 12345] is an example)
(Code example: kick $chan $2 $read(reasonkick.txt) [id: %knum])

[10 Mins later i set mode unban]
* Robert sets mode -b *!*@01.11.21.22

[Then 5 Mins later Nickname petra comeback and join #myroom]
* petra (abc@01.11.21.22) joins #myroom
* MyBot sets mode: + b *!*@01.11.21.22
* petra was kicked from #myroom by MyBot (Bye! You are not welcome here [id: 12345])

MyBot kick with older reason, how to make a code like that? Can you help me write that code? Thank you very much for your help and look forward to receiving your help soon.

Last edited by Robert; 29/04/21 03:29 PM. Reason: Explain exactly i means again
Re: How to kick with older reason? Help me pls [Re: Robert] #268792 29/04/21 02:45 PM
Joined: Feb 2009
Posts: 24
W
WKN Offline
Ameglian cow
Offline
Ameglian cow
W
Joined: Feb 2009
Posts: 24
Why does MyBot set mode -b if you want that user not to join at all anymore? Would be unnecessary Kick-Ban-Loop.

Re: How to kick with older reason? Help me pls [Re: WKN] #268793 29/04/21 03:18 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
That's is an example. So, i must be able to set 10mins for banned and auto unban after 10mins, because i don't want list of bans is full and list of akick is full

My purpose is how to get MyBot banned and kicked someone with an older reason kicked earlier.

Thanks!

Re: How to kick with older reason? Help me pls [Re: Robert] #268794 30/04/21 12:24 AM
Joined: Jan 2004
Posts: 1,558
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,558
Not sure I understand what you're wanting. If you want to only have a temporary ban along with the kick, you can have the bot do it like:

/ban -ku600 NICK 2 message goes here

... and the bot's mirc will remove the ban 600 seconds later. Is what you're wanting is to have the bot remember the nicks that it's hit with a temp-ban, and if they come again, it should ban them again for another 10 minutes using the same "reason" message again? If so, if that nick comes in again using a different host, are you wanting it to remember the same-nick or same-host for a future ban?

Re: How to kick with older reason? Help me pls [Re: maroon] #268795 30/04/21 01:15 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
MyBot will remember the IP address and Reason Kick. If anyone using that IP in the room will be banned and Kicked with reason has been kicked before
maroon, thanks for your answer. I want MyBot remember "reason kick" on the ip/host only. Can you help me to make a code like that pls?

Last edited by Robert; 30/04/21 01:36 PM.
Re: How to kick with older reason? Help me pls [Re: Robert] #268796 30/04/21 02:25 PM
Joined: Jan 2004
Posts: 1,558
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,558
I do not see anything in your example which shows how the text was chosen to be applied to petra. How does the "you are not welcome" reason get attached to Petra? is it randomly chosen from many items in the text file? Or is it the text attached to the ID 12345? Can 2 different people have the same text attached to 2 different ID numbers, or does 12345 for everyone always mean that same text?

Does the bot need to remember all the bans after restarting itself? Or only after it reconnects to the server?

How should the bot forget the ban, by being told to forget the ban against a host, or forget an ID number, or other way?

Re: How to kick with older reason? Help me pls [Re: maroon] #268797 30/04/21 02:38 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
1. How does the "you are not welcome" reason get attached to Petra? is it randomly chosen from many items in the text file? <=== yes (kickreason.txt there are some reasons like this:
You are not welcome here (next line)
The Operator is always right
....
2. Can 2 different people have the same text attached to 2 different ID numbers <--- this one. May be have the same text attached, but differnt ID numbers. (The kick ID is assigned randomly to any given IP (*!*@ip/host), when Op uses the command: .b <nickname> or .b <ip example: *! * @ 01.02.03.04>)

3. Does the bot need to remember all the bans after restarting itself? <=== yes

4. How should the bot forget the ban, by being told to forget the ban against a host, or forget an ID number, or other way? <==== when i deleted it from blacklist.txt only.

Last edited by Robert; 30/04/21 02:44 PM.
Re: How to kick with older reason? Help me pls [Re: Robert] #268798 30/04/21 04:04 PM
Joined: Jan 2012
Posts: 113
Epic Online
Vogon poet
Online
Vogon poet
Joined: Jan 2012
Posts: 113
From the above, I basically figured out what you want your bot to do and I am almost done creating my version of the script for you. It will probably be ready today.

Regarding the further automatic kick, would not it be easier to do it through the service command "/msg ChanServ help AKICK" ??? (assuming your services have such a module function)

Otherwise, the bot will have to create its own database with a list of banned users for automatic execution (kick + ban) in the future, referring to this list.


πŸ…ΈπŸ†πŸ…² - 𝔦'𝔱𝔰 𝔸 π•‚π–ŽΙ΄π™™ ᴏ𝙛 π•„π™–π–Œπ™žπ™˜
Re: How to kick with older reason? Help me pls [Re: Epic] #268799 01/05/21 12:09 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
1. From the above, I basically figured out what you want your bot to do and I am almost done creating my version of the script for you. It will probably be ready today. <=== Thank you very much and I hope to look forward to receiving your code today. You are awesome and good at coding

2. Regarding the further automatic kick, would not it be easier to do it through the service command "/msg ChanServ help AKICK" ??? (assuming your services have such a module function) <=== i don't want to use chanserv akick and my services have NOT such a module funtion smile

2. Otherwise, the bot will have to create its own database with a list of banned users for automatic execution (kick + ban) in the future, referring to this list. <=== I like this way. Can you write that code for me.

You are so smart that you understand my wording and know what I want in my Bot. Thank you if you help write this code for me soon. Best regards !

Re: How to kick with older reason? Help me pls [Re: Robert] #268800 01/05/21 05:39 PM
Joined: Jan 2012
Posts: 113
Epic Online
Vogon poet
Online
Vogon poet
Joined: Jan 2012
Posts: 113
So, I created my script for you. Most likely this is what you wanted. When tested under my conditions, it performed well. It is possible that when used in your conditions, something may go wrong, so I suggest you test this script thoroughly and watch it work.

Akick Temp Ban v1.0 – description:

  1.Sets a temporary ban, which is automatically removed after a while and the intruder is entered into the database for subsequent auto-ban.
  2.You can use the command with the syntax: "!b <nick>". (All nicknames for which this command will be available are recorded in the "%atb_admins" or who has a channel operator prefix "%atb_prefix").
  3.Through the alias "atb_set" you can customize the configuration parameters work of the script, changing the value of variables:

     %atb_work – configures enable or disable for work of the script. The options are: <yes|no>.
     %atb_kick – configures enable or disable the ability to install kicks. The options are: <yes|no>.
     %atb_akick – configures enable or disable of the user's record in the database for the subsequent auto-ban. The options are: <yes|no>.
     %atb_notice – configures enable or disable of sending a report to the notice message. The options are: <yes|no>.
     %atb_private – configures enable or disable sending a report to a private message. The options are: <yes|no>.
     %atb_comm – contains a command for the channel, after which the bot will execute the script function. Default: <!b>. (You can change this to any command you like).
     %atb_btype – configures the type (format) of the ban for the offender. More details about the types of bans are described here: $mask. Default: <2>.
     %atb_chans – contains a comma-separated list of channels on which the bot should execute the script function. The options are: <#test,#myroom|all>. (You can specify "all" to work on all channels).
     %atb_reason – contains the path to a text file with a list of reasons for the kick. By default, it is assumed that the file will be located in the same place as the script: <$scriptdir $+ atb_reason.txt>.
     %atb_pathdb – contains the path to the text file with the database, where the data of the violators will be saved. By default, the file will be located where the script: <$scriptdir $+ atb_database.txt>.
     %atb_icons – contains additional comma-separated icons (Unicode emoji) for add to the kick reason. Default: <πŸ”¨,✞,☠>. (Optional parameter, can be left blank or set "–". You can also add your own icons).
     %atb_time – contains the time for which a temporary ban will be set. Correct format: <1s|1m|1h|1d>.
     %atb_admins – contains a comma-separated list of aliases that are allowed to control the script. (Optional parameter, can be left blank or set "–". You can also specify other nicknames).
     %atb_prefix – contains prefixes, separated by commas, that must appear next to the alias (channel operator) who is allowed to control the script. Default: <[!,~,&,@,%]>. (If necessary, you can leave this field blank: "[]").

Demo screenshot of the script's operability:

     [Linked Image from i.ibb.co]

Click on the button to reveal the spoiler. This code must be inserted into the scripts editor. To do this, press the key combination "ALT+R" and save this code as new "File/New" script called "AkickTempBan.mrc":


Code
#####################################################################
#   Name: Akick Temp Ban v1.0
#   Author: Epic (epicnet@mail.ru, http://epicnet.ru)
#   Description: Sets a temporary ban, which is automatically removed after a while and the intruder is entered into the database for subsequent auto-ban.
#####################################################################

alias atb_set {
  %atb_work = yes
  %atb_kick = yes
  %atb_akick = yes
  %atb_notice = yes
  %atb_private = no
  %atb_comm = !b
  %atb_btype = 2
  %atb_chans = all
  %atb_reason = $scriptdir $+ atb_reason.txt
  %atb_pathdb = $scriptdir $+ atb_database.txt
  %atb_icons = πŸ”¨,✞,☠
  %atb_time = 5m
  %atb_admins = Epic,Robert
  %atb_prefix = [!,~,&,@,%]
}
=====================================================
on *:TEXT:*:#:{
  atb_set | if (%atb_work == yes) {
    if (%atb_chans == all) || ($istok(%atb_chans,$chan,44)) {
      if ($strip($1) == %atb_comm) {
        var %atb_up $remove($nick($chan,$nick).pnick,$nick) | var %atb_knick $strip($2)
        if (!$count($nick($chan,$me).pnick,%,@,&,~,!)) { .notice $nick I have no channel rights. Required prefix: !,~,&,@,% | halt }
        if (!$istok(%atb_admins,$nick,44) && $sprefix(%atb_up,%atb_prefix,44) == $false) { .notice $nick You do not have sufficient rights to execute this command. Required prefix: $remove(%atb_prefix,[,]) | halt }
        if ($2 == $null) { .notice $nick Correct syntax: %atb_comm <nick> | halt }
        if (!$comchan(%atb_knick,0).nick) { .notice $nick I do not see on the channels a nickname: %atb_knick | halt }
        var %atb_banid $+([ID:,$chr(32),$rand(A,Z),$rand(A,Z),$rand(1000,9999),])
        atb_bankick $chan %atb_knick %atb_banid    
        if (%atb_akick == yes) {
          if (!$read(%atb_pathdb, -w, $+(*,%atb_knick,*)) && !$read(%atb_pathdb, -w, $+(*,$address(%atb_knick,%atb_btype)))) {
            .write -il1 $qt(%atb_pathdb) $+(%atb_banid,$chr(44),%atb_knick,$chr(44),$address(%atb_knick,%atb_btype))
          }
        }
        if (%atb_notice == yes) { .notice $nick AkickTempBan: %atb_knick - $+($chr(40),%atb_time,$chr(41)) %atb_banid }
        if (%atb_private == yes) { .msg $nick AkickTempBan: %atb_knick - $+($chr(40),%atb_time,$chr(41)) %atb_banid }
      }
    }
  }
}
on *:JOIN:#:{
  atb_set | if (%atb_work == yes) {
    if (%atb_chans == all) || ($istok(%atb_chans,$chan,44)) {
      if ($read(%atb_pathdb, -w, $+(*,$nick,*))) || ($read(%atb_pathdb, -w, $+(*,$address($nick,%atb_btype)))) {
        var %atb_jbanid $gettok($read(%atb_pathdb,$readn),1,44) | atb_bankick $chan $nick %atb_jbanid
      }
    }
  }
}
-----------------------------------------------------
alias atb_bankick {
  .ban $+(-u,$convertsec(%atb_time)) $1 $2 %atb_btype
  if (%atb_kick == yes) {
    if (%atb_icons != $null) var %atb_i $gettok(%atb_icons,$rand(1,$numtok(%atb_icons,44)),44)
    if ($exists(%atb_reason) == $true) var %atb_r Bye! - $read(%atb_reason) | else var %atb_r Bye! - You are banned
    .kick $1 $2 %atb_i %atb_r $3-
  }
}
alias sprefix {
  var %sp_sp $remove($2,[,]) | var %sp_sn $numtok(%sp_sp,$3)
  var %q 1 | while (%q <= %sp_sn) { if ($gettok(%sp_sp,%q,$3) isin $1) return $true | inc %q } | return $false
}
alias convertsec {
  var %cst $right($1,1) | var %csn $remove($1,%cst)
  if ($count(%cst,s,m,h,d)) {
    if (%cst == s) return %csn
    if (%cst == m) return $calc(%csn * 60)
    if (%cst == h) return $calc(%csn * 3600)
    if (%cst == d) return $calc(%csn * 86400)
  }
  else { .echo -s Error: Invalid time format - Correct format: 1s,1m,1h,1d | return 300 }
}



The script was tested on InspIRCD v3 + mIRC v7.63.

Remember that if something went wrong, or you accidentally erased something, then you can always reinstall this script again.
If you find any errors in the code and in its work, or maybe you have new ideas or if you think that this script needs to be improved, then be sure to write to me here about it, and we are together think about what we can do.

P.S. Thanks for your good words. I'm not a magician, I'm still on the path of knowledge ✨ cool ✨  To be fair, except me here there are many other professionals in the field of scripting, whose level I rate how very high ⭐⭐⭐, and who can do it even better than me. But the most important words of gratitude, of course, to Khaled for creating for all of us such a wonderful and multi-functional mIRC client with advanced capabilities thanks to scripts codes.




πŸ…ΈπŸ†πŸ…² - 𝔦'𝔱𝔰 𝔸 π•‚π–ŽΙ΄π™™ ᴏ𝙛 π•„π™–π–Œπ™žπ™˜
Re: How to kick with older reason? Help me pls [Re: Epic] #268801 02/05/21 02:01 AM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
WOW....Thank you Epic, you are number 1. That code work exactly i means and want.

1. But how to deleted (removed) ban? I open atb_database.txt to remove the Ip in here, but i can't see any Ip.

2. [ID: NU4810] <=== Please change it to [id: numberOnly]

3. I creat atb_reason.txt and put some reasons on it (1 reason per line) but MyBot doesn't kick with random reason

4. Can you remove the icon in front of the reason for the kick? (☠ πŸ”¨)

NOTE (IMPORTANT): In file atb_reason.txt i have 10 reasons from 1 to 10. If kick with random reasons from file atb_reason.txt: Example: if reason kick is reason2 and [id: randomnumber, example [id: 1234]] then next time auto kick with reason2 and [id: oldnumber 1234]. I thinks you make a code to save and remember ReasonKick and id number is the best way i guess :P

5. (New idea) If i type command: !b <Nickname> <reason> (Example: !b ChatNick Hello how are you today?) then MyBot will ban ip/host and kick with reason: Hello how are you today? [id: randomNumber,Ex:1234]. Next time this Ip/host rejoin room will be kicked with older reason anf kick id: Hello how are you today? [id: 1234]

6. Can you write code to check On Nick event.If Nick change ip/host then join room,and when change the Nick of kick above (the older Nick has been kick/ban before) will be banned ip/host and kicked with OlderReason and Older id number is: Hello how are you today? [id: 1234]

If i found an error i will tell you to fixed it. Thanks so much to Epic


Last edited by Robert; 02/05/21 05:48 AM.
Re: How to kick with older reason? Help me pls [Re: Robert] #268802 02/05/21 08:01 AM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
I have change something on your code like this:

https://pastebin.com/raw/AmENQK5G

BUT THERE IS A PROBLEM IS:

1. MyBot has been kicked with random reason from atb_reason.txt BUT on next time that person come back and rejoin my room, MyBot banned and kicked but with different reason,
not older reason has been kicked before. Can you fixed it for me. Thank you so much.

Re: How to kick with older reason? Help me pls [Re: Robert] #268803 02/05/21 11:21 AM
Joined: Jan 2012
Posts: 113
Epic Online
Vogon poet
Online
Vogon poet
Joined: Jan 2012
Posts: 113
Quote
1. But how to deleted (removed) ban? I open atb_database.txt to remove the Ip in here, but i can't see any Ip.

It all depends on what path you specified to save data in the file. If you want the file to be in the root folder of the client together with all other executable files,
then specify the path in the variable as follows: "%atb_pathdb = $mircdir $+ atb_database.txt", or any other path to file. For example: "%atb_pathdb = C:\atb_database.txt".
I think that the removal of records will be much more convenient if the ban ID or nickname will be specified in the command to delete: "!b <nick|id> del" or "!bd <nick|id>".

Quote
2. [ID: NU4810] <=== Please change it to [id: numberOnly]

You can remove from the variable value "%atb_banid" multiple identifiers for creating random alphabet letters: "$rand(A,Z),$rand(A,Z)":
Code
var %atb_banid $+([ID:,$chr(32),$rand(1000,9999),])

Quote
3. I creat atb_reason.txt and put some reasons on it (1 reason per line) but MyBot doesn't kick with random reason

The same as in the first question. Probably you did not correctly indicate the path in the variable "%atb_reason" where your file is.

Quote
4. Can you remove the icon in front of the reason for the kick? (☠ πŸ”¨)

Yes, you can simply delete them all or vice versa, add other badges, but necessarily through the comma: "%atb_icons = 😁,πŸ˜‡,😈" or leave dash, or space "%atb_icons = -".
Note: This variable should be used only for the icons (emoji). If you want to add to the message for kick some add static text,
then you can create new variables with any name in alias "atb_set" then you can insert this variable in the string ".kick $1 $2 %atb_i %atb_text1 %atb_r $3-":
Code
alias atb_set {
  ...
  %atb_text1 = Here is my new text1
  %atb_text2 = Here is my new text2
  %atb_text3 = Here is my new text3
}

Quote
NOTE (IMPORTANT): In file atb_reason.txt i have 10 reasons from 1 to 10. If kick with random reasons from file atb_reason.txt: Example: if reason kick is reason2 and [id: randomnumber, example [id: 1234]] then next time auto kick with reason2 and [id: oldnumber 1234]. I thinks you make a code to save and remember ReasonKick and id number is the best way i guess :P

Yes, this can be added to save in the database.

Quote
5. (New idea) If i type command: !b <Nickname> <reason> (Example: !b ChatNick Hello how are you today?) then MyBot will ban ip/host and kick with reason: Hello how are you today? [id: randomNumber,Ex:1234]. Next time this Ip/host rejoin room will be kicked with older reason anf kick id: Hello how are you today? [id: 1234]

Yes, this can also be added to this team. In addition, I think it will be necessary to additionally record the #Channel itself in the database in the line along with the nick.

Quote
6. Can you write code to check On Nick event.If Nick change ip/host then join room,and when change the Nick of kick above (the older Nick has been kick/ban before) will be banned ip/host and kicked with OlderReason and Older id number is: Hello how are you today? [id: 1234]

Yes, this will be logical. I will add event handler "on NICK" to check the changes in the nicknames.


Okay, I will make all these changes in the code, taking into considering your remarks and new proposals.




πŸ…ΈπŸ†πŸ…² - 𝔦'𝔱𝔰 𝔸 π•‚π–ŽΙ΄π™™ ᴏ𝙛 π•„π™–π–Œπ™žπ™˜
Re: How to kick with older reason? Help me pls [Re: Epic] #268804 02/05/21 12:03 PM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
Yes, this will be logical. I will add event handler "on NICK" to check the changes in the nicknames.


Okay, I will make all these changes in the code, taking into account your remarks and new proposals.


Thanks Epic forever so much! I'm waiting for new code from you and I hope will receive your code soon, Best regards!

Re: How to kick with older reason? Help me pls [Re: Robert] #268807 03/05/21 03:13 AM
Joined: Mar 2021
Posts: 14
R
Robert Offline OP
Pikka bird
OP Offline
Pikka bird
R
Joined: Mar 2021
Posts: 14
Dear Epic, i have an idea for you to make code :P

1. When Admin type command: !b <NickName> in every channels Bot have Op, then MyBot will banned IP/HOST (default $address 2) and kicked that NickName with RANDOM REASON on file text atb_reason.txt AND AUTO SAVE [id: number]; NickName; IP/HOST and REASONKICK like this in atb_database.txt file text:

Example:
Line1: [id: number],NickName,*!*@IP/HOST,ReasonKick <==== If this NickName or IP/HOST join myroom will be kicked and banned with this ReasonKick and [id: number] in atb_database.txt.

Line2: similar above.....
Line3:.....etc........

2. I have already to make some commands to add blacklisted user to atb_database.txt with syntax:

a) Add Auto ban command: !badd [id: number],NickName,*!*@IP/HOST,ReasonKick

Example: !badd [id: 5864],BlackNick,*!*@10.11.12.13,You are bad chatter not welcome here


b)Del Auto ban: !bdel [id: number],NickName,*!*@IP/HOST,ReasonKick or !bdel NumberWantToDeleted

Example: + !bdel [id: 5864],BlackNick,*!*@10.11.12.13,You are bad chatter not welcome here
OR + !bdel 2

c) List Auto ban: !blist <== then MyBot will list all of auto ban blacklisted in atb_database.txt to channel

Send you for reference and for the purpose of writing code is more convenient and correct for me. Thanks Epic so much! You are so kind and wonderful