| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Fri May 01, 2015 5:30 pm Post subject: Bot managing services |
|
|
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:
| Quote: | | !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:
| Quote: | | 'Requested service shortly an administrator will managing request' |
If any of the conditions is not met, the bot will respond:
| Quote: | | The request must be made by the founder of the channel, | or
| Quote: | | The channel has NOT 10 days registration. |
Then, if two conditions are met, when the admin write command:
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  |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat May 02, 2015 10:29 am Post subject: |
|
|
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 ! |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat May 02, 2015 11:48 am Post subject: |
|
|
| 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.: | Quote: | | /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  |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat May 02, 2015 2:39 pm Post subject: |
|
|
| 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: |
# 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 ! |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat May 02, 2015 4:31 pm Post subject: |
|
|
Here is something more for you to experiment with. I think it demonstrates some more of the things you are wanting to do.
| Code: |
# 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 ! |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat May 02, 2015 6:53 pm Post subject: |
|
|
willyw worked perfect!
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  |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat May 02, 2015 9:20 pm Post subject: What is wrong? |
|
|
When I add the channel to the bot and this join the room, use | Quote: | | 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?:
| Quote: | | if {$count >= 10 } |
while you are running the while ?
I could not fix it
| Code: |
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  |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat May 02, 2015 9:37 pm Post subject: Re: What is wrong? |
|
|
| juanamores wrote: | When I add the channel to the bot and this join the room, use | Quote: | | 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?:
| Quote: | | if {$count >= 10 } |
while you are running the while ?
|
Probably.
| Quote: |
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 ! |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat May 02, 2015 9:50 pm Post subject: Re: What is wrong? |
|
|
| 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  |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Sat May 02, 2015 10:04 pm Post subject: Re: What is wrong? |
|
|
| 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 ! |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat May 02, 2015 10:41 pm Post subject: Re: What is wrong? |
|
|
| 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:
| Quote: | | 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: |
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  |
|
| Back to top |
|
 |
|
|
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
|
|