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 

Read private message ChanServ bot ?

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


Joined: 15 Mar 2015
Posts: 317

PostPosted: Sun Apr 12, 2015 1:29 pm    Post subject: Read private message ChanServ bot ? Reply with quote

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:
Quote:
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:
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
..............
Back to top
View user's profile Send private message
Get_A_Fix
Master


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Tue Apr 14, 2015 9:43 am    Post subject: Reply with quote

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:

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 Smile
_________________
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.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Apr 14, 2015 2:17 pm    Post subject: Reply with quote

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

I was trying to read the private messages sent by the bot CHaN directly:
Quote:
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 Razz
Back to top
View user's profile Send private message
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Tue Apr 14, 2015 6:21 pm    Post subject: Reply with quote

I got back to my house and as I promised I will share the code.
Code:
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 Smile
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