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.

Bot managing services

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

Bot managing services

Post by juanamores »

I want to create a TCL for managing mi future services radio bot.
I want in particular, that when a founder of a channel join at BOt channel, and for example write command:
!Requests #channelx
the bot checks two conditions:
a) the request is performing for #channelx founder, and
b) the #channelx have minimum 10 days of registration in the network.
If both conditions are met, the bot will respond:
'Requested service shortly an administrator will managing request'
If any of the conditions is not met, the bot will respond:
The request must be made by the founder of the channel,
or
The channel has NOT 10 days registration.
Then, if two conditions are met, when the admin write command:
!go #channelx
the bot join to this channel and verify that the channel has a minimum of x users (without bots, here you can make a list of known bots and compare that, to remove them of count, and if possible, not counting the clones) and after verifying the requirements of users part this channel, if all OK, the bot will report to management channel and the admin will added this channel at bot and definitely send the bot to that channel.
You know any TCL, do those checks?
At least to have a basis to begin to modify it, and not work of zero.
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 :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

This kind of script could easily be very specific to the network on which it will be used.

For anyone to be able to help you, they would need more info:
The network, and its address
The name of Channel Services. Often it is Chanserv.
The name of Nick Services. Often it is Nickserv.
Anything else that you can think of, that might be useful to the scripter.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

willyw wrote:This kind of script could easily be very specific to the network on which it will be used.

For anyone to be able to help you, they would need more info:
The network, and its address
The name of Channel Services. Often it is Chanserv.
The name of Nick Services. Often it is Nickserv.
Anything else that you can think of, that might be useful to the scripter.
willyw hello, you're right, without such data it is difficult to run a script. :)
The task to tailor the network to do it myself, if I had at least one base of a code from another network, but not to do it from scratch.
Network: irc.chathispano.com or miranda.chathispano.com
Channel Services: CHaN
Nick Services: NiCK
I think it might be useful, the command for channel information, for example, founder, date of registration, etc.:
/msg CHaN info #channel
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 :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

juanamores wrote: ...
The task to tailor the network to do it myself,
....
Excellent! :)

You have another thread here somewhere. The below is related to it, so I'm sure you and figure out what is going on here.

Play with this, and you'll quickly see what it does. Then you can adapt it to your needs.

Code: Select all


# May 2, 2015

# http://forum.egghelp.org/viewtopic.php?p=103991#103991


set canal_admin "#channel"
set canal_radio "#channel2"


bind pub * !request ver_chan
bind msgm - * info:channel


proc ver_chan {nick uhost hand chan text} {
global canal_admin canal_djs canal_radio
        if {[llength $text] != 1} { putmsg $canal_radio "canal invalido XD"; return }

        set canal [lindex [split $text] 0]
        ##Send your query to the bot CHaN by the channel info.
        putserv "PRIVMSG chan :info $canal"
}


proc info:channel {nick CHaN!-@- hand text} {
global canal_admin

        if {[lindex [split $text] 0] eq "Registrado:"} {
                putserv "privmsg $canal_admin :Registrado is: $text"

                set reg_date [lindex [split $text] 2]

                putserv "privmsg $canal_admin :reg_date is: $reg_date"

                putserv "privmsg $canal_admin :Reg days old is: [duration [expr [unixtime] - [clock scan $reg_date -format {%d/%b/%Y} -locale ES]  ]]"

                set reg_date_unixtime [clock scan $reg_date -format {%d/%b/%Y} -locale ES]

                putserv "privmsg $canal_admin :10 days ago was :[clock format [clock add [clock seconds] -10 day] -locale ES]"

                set 10_days_ago_unixtime [clock add [clock seconds] -10 day -local ES ]

                if {$10_days_ago_unixtime > $reg_date_unixtime} {
                        putserv "privmsg $canal_admin :Channel has been registered more than 10 days"
                } else {
                        putserv "privmsg $canal_admin :Channel has been registered less than 10 days"
                }

        }

        return 0
}
Reference: http://www.tcl.tk/man/tcl8.5/TclCmd/clock.htm
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Here is something more for you to experiment with. I think it demonstrates some more of the things you are wanting to do.

Code: Select all


# May 2, 2015


# http://forum.egghelp.org/viewtopic.php?t=19952


bind pub n "!go" join_chan


proc join_chan {nick uhost handle chan text} {

        if {![llength [split $text]]} {
                putserv "privmsg $chan :Syntax: !go #channel"
                return 0
        }

        set chan_to_add [lindex [split $text] 0]

        channel add $chan_to_add

        #introduce a delay, to give bot time to get into channel, and
        # get the list of users currently in the chan.
        # You may be able to adjust this down some.
        utimer 10 [list count_users $chan $chan_to_add ]

}


proc count_users {chan chan_to_add} {

        set num_nicks [llength [chanlist $chan_to_add]]

        putserv "privmsg $chan :Number of nicks on $chan_to_add is: $num_nicks"

        set fname "scripts/added/experiment_for_somebody/list_of_bots.txt"
        set fp [open $fname "r"]
        set data [read -nonewline $fp]
        close $fp

        #set lines [split $data "\n"]
        set bot_nicks_list [split $data]

        putserv "privmsg $chan :list of bot nicks is: $bot_nicks_list"

        set nick_counter 0
        foreach n [chanlist $chan_to_add] {
                if {[lsearch -nocase $bot_nicks_list $n] > -1} {
                        putserv "privmsg $chan :$n is in bots nick list"
                } else {
                        incr nick_counter
                }
        }
        putserv "privmsg $chan :Number of nicks on $chan, not including nicks found in bots list is: $nick_counter"



        set dupecounter 0
        foreach n [chanlist $chan_to_add] {
                foreach nn [chanlist $chan_to_add] {
                        if {$n eq $nn} {
                                break
                        }
                        if {[getchanhost $n $chan_to_add] eq [getchanhost $nn $chan_to_add]} {
                                putserv "privmsg $chan :$n and $nn are have same hostmask"
                                incr dupecounter
                        }
                }
        }
        putserv "privmsg $chan :dupe count is: $dupecounter"
        putserv "privmsg $chan : "
        putserv "privmsg $chan :Number of nicks, minus bots, and minus dupes is: [expr $nick_counter - $dupecounter]"

}

I hope this helps you with your efforts to put something together yourself. :)
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

willyw worked perfect! :D
Now, I'm working on another part of the code, when the bot joins the requested channel and does the counting of users. :)
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 :)
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

What is wrong?

Post by juanamores »

When I add the channel to the bot and this join the room, use
foreach users [chanlist $newchan]
to count channel users.
The bot part channel immediately.
Why not take value count variable?
The value is always a blank.
You will need a timer before?:
if {$count >= 10 }
while you are running the while ?

I could not fix it :?

Code: Select all

bind pub a|n !go pub:go
set canal_admin "#chan0"
set canal_radio "#chan1" 


proc pub:go {nick host hand chan text} {
   global canal_admin
   if { $chan != $canal_admin} { return 0 }
    set newchan [lindex [split $text] 0]
     if {$newchan == ""} {
      putmsg $canal_admin "$nick, Enter channel."
      return 0
   }
      if {![validchan "$newchan"]} {
##Add channel and join###
          channel add $newchan
          putquick "PRIVMSG $canal_admin :$nick Ok, join $newchan ..."
         set count 0
##Counting users $newchan###        
foreach users [chanlist $newchan] {
  ####For debuggin purpose###     
putquick "PRIVMSG $canal_admin :counting $newchan users..."
         incr count
     }
##HERE $count not take value, is always a blank##
if {$count >= 10 } {
putquick "PRIVMSG $newchan :channel accepted, I came to stay :\)"
putquick "PRIVMSG $canal_admin : \0032$newchan was verified and accepted has $count users.." 
 return 0
} else {
channel remove $newchan
putquick "PRIVMSG $canal_admin :\0032$newchan was verified and NOT accepted has $count users.." 
return 0 }
} else {
       putquick "PRIVMSG $canal_admin : \002$newchan\002 has already been verified and is in my database.! "
      return 0
   }
}   
   
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 :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: What is wrong?

Post by willyw »

juanamores wrote:When I add the channel to the bot and this join the room, use
foreach users [chanlist $newchan]
to count channel users.
The bot part channel immediately.
Why not take value count variable?
The value is always a blank.
You will need a timer before?:
if {$count >= 10 }
while you are running the while ?
Probably.
I could not fix it :?
Look at the way I did it, in an earlier post here.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Re: What is wrong?

Post by juanamores »

willyw wrote: Look at the way I did it, in an earlier post here.
And I added a timer, but can not count the number of channel users. :S
EDIT:
The strangest thing is that even NOT takes the value of zero with which was seted before.
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 :)
w
willyw
Revered One
Posts: 1205
Joined: Thu Jan 15, 2009 12:55 am

Re: What is wrong?

Post by willyw »

juanamores wrote:
willyw wrote: Look at the way I did it, in an earlier post here.
And I added a timer, ...

Post your code. All of it.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Re: What is wrong?

Post by juanamores »

willyw wrote:
juanamores wrote:
willyw wrote: Look at the way I did it, in an earlier post here.
And I added a timer, ...

Post your code. All of it.
Friend, just I discovered the problem.
Two timers are needed, one after the add channel, and other before comparing the number of users.
The problem is that a variable depends on another and it becomes a vicious circle.
Thus is the code fails:
Tcl error [pub:go]: can't read "countuser": no such variable
This is because the 1st timer culminated not running the first proc (vericount0) and does not send the value to the second proc (vericount).

Code: Select all

bind pub a|n !go pub:go
set canal_admin "#chan0"
set canal_radio "#chan1"


proc pub:go {nick host hand chan text} {
   global canal_admin
   if { $chan != $canal_admin} { return 0 }
    set newchan [lindex [split $text] 0]
     if {$newchan == ""} {
      putmsg $canal_admin "$nick, Enter channel."
      return 0
   }
      if {![validchan "$newchan"]} {
##Add channel and join###
          channel add $newchan
          putquick "PRIVMSG $canal_admin :$nick Ok, join $newchan ..."
##I must add a timer to allow time to recognize the newly added channel.
   
utimer 15 [list vericount0 $nick $canal_admin $newchan]
proc vericount0 { nick canal_admin newchan}  {
	  set countuser 0
	  foreach n [chanlist $newchan] {
	  if {$countuser >= 10} break
	   putquick "PRIVMSG $canal_admin :counting users of $newchan... COUNT value: $countuser"
       putquick "PRIVMSG $canal_admin :$n ..."
      set countuser [expr {$countuser + 1}]
	  putquick "PRIVMSG $canal_admin :contuser value now: $countuser"
     }}
	 utimer 30 [list vericount $nick $canal_admin $newchan $countuser]
proc vericount { nick canal_admin newchan countuser} {
putquick "PRIVMSG $canal_admin : countuser: $countuser"
if {$countuser >= 10 } {
putquick "PRIVMSG $newchan :channel accepted, I came to stay :\)"
putquick "PRIVMSG $canal_admin : \0032$newchan was verified and accepted has $count users.." 
 return 0
} 
channel remove $newchan
putquick "PRIVMSG $canal_admin :\0032$newchan was verified and NOT accepted has $count users.." 
return 0 
 }     
} else {
 putquick "PRIVMSG $canal_admin : \002$newchan\002 has already been verified and is in my database.! " 
      return 0
}}
EDIT: Solved I fixed timers
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