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.

Read private message ChanServ bot ?

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Read private message ChanServ bot ?

Post by juanamores »

This is another idea that occurred to me to know if a nick is registered in the network, when adding it to the staff.

When trying to add unregistered nick, at a channel of a network, the CHaN bot send this private message:
The channel access list should only contain registered nicknames.
I need, my bot read the private message that sends CHaN and it search any of those words ('only contain nicks registered ').

If you find any of these words means the nick you are trying to add to the staff of the bot, it is not registered on the network.

Code: Select all

bind pub o|o !fanadd add_fan
set chan_radio "#myradio"
proc add_fan {nick uhost hand chan text} {
global chan_radio
  if {$text == ""} {putmsg $chan "You must enter the nick of the fan to add!";return 0}
 set fan [join [lindex [split $text] 0]]

# The following command adds a nick level 100 IRC IRCu Network
putserv "PRIVMSG CHaN :access $chan_radio add $fan 100"

###HERE I need, my bot read the private message that sends CHaN and it search any of those words ('only contain nicks registered ').. ###

 If the bot found some of those words means that the nick is not registered on the network. { putmsg $chan "Can not add to staff a nick NO Signup!";return 0
  } else {
continue
..............
User avatar
Get_A_Fix
Master
Posts: 206
Joined: Sat May 07, 2005 6:11 pm
Location: New Zealand

Post by Get_A_Fix »

This is a simple little 'autovoice' script I made for someone, who ONLY wanted to voice Registered User's on their network. You may have to do some checking of your own, just to make sure that the RAW numeric used in this example script is the same on the IRCd you and your bot are using.

Code: Select all

bind raw - 307 auth_check 
bind join - * join_routine 
 
setudef flag authcheck 
 
proc join_routine {nick uhost hand chan arg} { 
  if {![channel get $chan authcheck]} {return} 
  if {![isbotnick $nick] && ![validuser [nick2hand $nick]]} { 
    putserv "WHOIS $nick" 
  } 
} 
 
proc auth_check {from keyword args} { 
  if {![string match "*is a registered nick*" $args]} {return} 
  set nick [lindex [split $args] 1] 
   foreach chan [channels] { 
    if {![onchan $nick $chan] && ![channel get $chan authcheck] && [validuser [nick2hand $nick]] && [isop $nick $chan] && [isvoice $nick $chan]} {return} 
    putquick "MODE $chan +v $nick" 
  } 
}
If you are able to see the method to this concept, then you should have no problem using the RAW and a procedure to check /whois and match the string "*is a registered nick*".

This also uses a setudef (user defined setting) of 'authcheck'. This means that you can use .chanset in DCC/Telnet/Partyline to enable/disable the code on a channel by channel basis. It's always smart to be able to turn things on|off :)
We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Thanks Get_A_Fix for this new idea, it will be very useful. :)

I was trying to read the private messages sent by the bot CHaN directly:
bind msgm - CHaN!*@* process: reg
Then in the process :reg, seeks the words "only contain registered nicknames" and store the result in a file (0 if the nick is registered and 1 if the nick is not registered).
These values stored in the file, will consult when adding a user to the staff.
Now I'm at work when I get home, I will publish the complete solution, if it's any help to other users.

Sorry for mi bad english :P
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

I got back to my house and as I promised I will share the code.

Code: Select all

bind pub oa|n !fieladd add_fan
bind pub oa|n !djadd add_dj
bind pub a|n !adminadd add_admin
bind pub n|n !rootadd add_root

#bind msgm <flags> <mask> <proc>, The CHaN bot mask is *!-@-#

bind msgm - *!-@- fiel:registro 
bind msgm - *!-@- dj:registro 
bind msgm - *!-@- admin:registro 
bind msgm - *!-@- root:registro 

set canal_radio #channel1
set canal_djs #channel2
set canal_admin #channel3

proc add_fan {nick uhost hand chan text} {
  global canal_radio canal_djs  canal_admin
   if {$text == ""} {putmsg $chan "You must enter the nick of the fan to add!";return } 
  set fan [join [lindex [split $text] 0]]
  set faninv "$ndj[join !*@*]"
  putserv "PRIVMSG chan :access $canal_radio add $fan 100"
if {![file exists regfiel]} {
set fs [open "regfiel" w+]
puts $fs 0
close $fs
set temp [open "regfiel" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else { 
if {[file exists regfiel]} {
    set temp [open "regfiel" r]
    set reg [gets $temp]
	set nickreg [lindex $reg 0]
    close $temp
	}} 
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}  
 if {$nickreg == 0 } { 
.................more stuff...........

proc add_dj {nick uhost hand chan text} {
.......
Similar lines to the above process
........

if {![file exists regdj]} {
set fs [open "regdj" w+]
puts $fs 0
close $fs
set temp [open "regdj" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else { 
if {[file exists regdj]} {
    set temp [open "regdj" r]
    set reg [gets $temp]
	set nickreg [lindex $reg 0]
    close $temp
	}} 
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}  
 if {$nickreg == 0 } { 
.................more stuff...........

proc add_admin {nick uhost hand chan text} {
.......
Similar lines to the above process
........

if {![file exists regadm]} {
set fs [open "regadm" w+]
puts $fs 0
close $fs
set temp [open "regadm" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else { 
if {[file exists regadm]} {
    set temp [open "regadm" r]
    set reg [gets $temp]
	set nickreg [lindex $reg 0]
    close $temp
	}} 
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}  
 if {$nickreg == 0 } { 
.................more stuff...........

proc add_root {nick uhost hand chan text} {
.......
Similar lines to the above process
........

if {![file exists regroot]} {
set fs [open "regroot" w+]
puts $fs 0
close $fs
set temp [open "regroot" r]
set reg [gets $temp]
set nickreg [lindex $reg 0]
close $temp
} else { 
if {[file exists regroot]} {
    set temp [open "regroot" r]
    set reg [gets $temp]
	set nickreg [lindex $reg 0]
    close $temp
	}} 
if {$nickreg == 1} { putmsg $chan "Can not add to staff a nick NO Signup!";return}  
 if {$nickreg == 0 } { 
.................more stuff...........

#procname <nick> <user@host> <handle> <text> The user@host of bot CHaN is CHaN!-@- #

proc fiel:registro {nick CHaN!-@- hand text} {
 if {[string match -nocase "*only contain registered nicknames*" $text]} {
  set fs [open "regfiel" w+]
  puts $fs 1
  close $fs
  return 
 } else {
 set fs [open "regfiel" w+]
  puts $fs 0
  close $fs
 }}

 proc dj:registro {nick uhost hand text} {
 if {[string match -nocase "*only contain registered nicknames*" $text]} {
  set fs [open "regdj" w+]
  puts $fs 1
  close $fs
  return 
 } else {
 set fs [open "regdj" w+]
  puts $fs 0
  close $fs
 }}
proc admin:registro {nick uhost hand text} {
 if {[string match -nocase "*only contain registered nicknames*" $text]} {
  set fs [open "regadm" w+]
  puts $fs 1
  close $fs
  return 
 } else {
 set fs [open "regadm" w+]
  puts $fs 0
  close $fs
 }}
  proc root:registro {nick uhost hand text} {
 if {[string match -nocase "*only contain registered nicknames*" $text]} {
  set fs [open "regroot" w+]
  puts $fs 1
  close $fs
  return 
 } else {
 set fs [open "regroot" w+]
  puts $fs 0
  close $fs
 }}
The problems that have arisen me are obvious:
Adding a fan, dj, admin or root, the 4 bind msgm events simultaneously triggers , because the 4 events used the same mask (*!-@-).
That makes who 4 files (regfiel, regdj, regadm and regroot) change their values, when wish who only one of them, change the value.

The code works fine, if only one of bot operators, adds a certain staff. i.e !addfan or !addj etc...

But, if simultaneously, several operators adds staff at the same time, a conflict is generated.

Is there any way that bind msgm events triggers individual for each level of staff adding?

Example:
While the operator A adds a DJ, only trigger event bind msgm - *!-@- dj:registro .
While the operator B adds simutaneamente A a ADMIN, only trigger event bind msgm - *!-@- admin:registro .

Reason Edit: add an example.
If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks :)
Post Reply