| View previous topic :: View next topic |
| Author |
Message |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Tue Apr 21, 2015 7:23 pm Post subject: Nicks On line and Off line RAW Numerics |
|
|
I am confused with the RAW number returned me is state of a nick on a network (on line or off line).
I created a text file with nicks (nicks.txt).
I want to put at channel, list nicks with their status (online, offline).
Example:
My text file contains the following nicknames: nick1 nick2 nick3.
Suppose that only nick1 and nick2 are online.
I want this:
| Quote: | nick1 is online
nick2 is online
nick3 is offline |
_________________ 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: Tue Apr 21, 2015 10:51 pm Post subject: Re: Nicks On line and Off line RAW Numerics |
|
|
EDIT: more info
My network accepts watch and ison commands. _________________ 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: Wed Apr 22, 2015 12:17 am Post subject: Re: Nicks On line and Off line RAW Numerics |
|
|
| juanamores wrote: | I am confused with the RAW number returned me is state of a nick on a network (on line or off line).
|
The raw numeric returned depends on what is causing it.
In your other thread, I mentioned this:
https://www.alien.net.au/irc/irc2numerics.html
That's one list.
(You can find others with Google.)
Text search it for
watch
and for
ison
They are in there.
Be sure to look up
bind raw
in : http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
so that you can get the right syntax when using a bind raw .
| Quote: |
I created a text file with nicks (nicks.txt).
|
And can you read it into a variable, with your script?
In your other thread here, I gave you a link to some very helpful
forum FAQ posts that show how to do it.
Have you mastered that, yet?
| Quote: |
I want to put at channel, list nicks with their status (online, offline).
Example:
My text file contains the following nicknames: nick1 nick2 nick3.
Suppose that only nick1 and nick2 are online.
I want this:
| Quote: | nick1 is online
nick2 is online
nick3 is offline |
|
You want this to be caused by what? A public command in a channel?
If so, you can use the IRC
ison
command in your script. _________________ 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: Wed Apr 22, 2015 12:21 am Post subject: Re: Nicks On line and Off line RAW Numerics |
|
|
| juanamores wrote: |
...
EDIT: more info
My network accepts watch and ison commands. |
It depends on what you want to do.
The watch command is a command to the IRC server itself. The server is the only way to get instant, server wide notification when a nick appears.
If that is what you want (I think you did want that, in your other post) , then this is the command to work with.
If you want to to create a public command, such that a user can call it from a channel, then you want to use the IRC server command - ison . _________________ 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: Wed Apr 22, 2015 8:12 pm Post subject: Re: Nicks On line and Off line RAW Numerics |
|
|
| willyw wrote: |
And can you read it into a variable, with your script?
In your other thread here, I gave you a link to some very helpful
forum FAQ posts that show how to do it.
Have you mastered that, yet?
|
Yes
| willyw wrote: |
You want this to be caused by what? A public command in a channel?
If so, you can use the IRC
ison
command in your script. |
Yes, too
I found this TCL and tried to modify it, to adapt the bind msg event bind pub event.
This was my attempt to modify:
| Code: | #---------------------------------------------------------------------
# ison.tcl
# TCL script for IRC bot eggdrop
#
# usage: !ison
#
# v0: 19-Sep-2002
#---------------------------------------------------------------------
package require eggdrop 1.6
package require Tcl 8.0
#---------------------------------------------------------------------
# command trigger for ison
#---------------------------------------------------------------------
set canal_admin #mychannel
#Path of txt file whith nicks
set notify1 "scripts/notify/notify.txt"
bind pub -|- !ison ison_trigger
proc ison_trigger {nick uhost hand chan text} {
global canal_admin notify1
if {![file exists $notify1]} {
putmsg $canal_admin "No such file (notify.txt) in path scripts/notify/"
return
} else {
set fp [open $notify1 "r"]
set data [read -nonewline $fp]
close $fp
set lines [split $data "\n"]
set first [lindex $lines 0]
if {$first == ""} {
set lines [lreplace $lines 0 0]
set fp [open $notify1 "w"]
puts $fp [join $lines "\n"]
close $fp
}
set largo [llength $lines]
if {$largo < 1} { putmsg $chan "\0032Notify database is empty"; return 0}
putmsg $canal_admin "\002\0032Status nicks (notify):"
set x 0
while {$x < $largo} {
set target [lindex $lines $x]
putlog "Sending ISON request for $target to server"
utimer 5 [list putserv "ISON $target"]
# log the ison request
return 1
incr x
}
putmsg $chan "\002\0032=====End of list ($largo nicks)====="
}
}
#---------------------------------------------------------------------
# Putlog RAW reply 303 and 461 by the server
#---------------------------------------------------------------------
bind RAW - 303 ison:raw
bind RAW - 461 ison:raw
proc ison:raw { server keyword arg } {
global canal_admin
# For debugging purposes.
putlog "RAW $keyword: $server, $arg"
>>>>>>>>>>(GIVING ERROR HERE, SEE THE END OF CODE COMMENTARY (*)<<<<<<<<<<<
# scan out the botnick, nick of requester and other response.
if {[scan $arg "%s :%s %\[^\n\]" bot nick response] != 3 } {
puthelp "PRIVMSG $canal_admin :$response IS OFF line IRC"
} else {
puthelp "PRIVMSG $canal_admin :$response IS On line IRC"
}}
putlog "Loaded (version 0): demo ISON script." |
(*)COMMENTARY ERROR:
Here the code fails the argument (arg) returns the bot nick, space and two point ( .
$arg should return the value of the $target variable (ie, one nick of the list).
This code was intended by its author, for it to be used by typing /msg bot nick ison with the 'bind msg' event.
I changed the code to work with 'bin pub'.
It is clear that bind RAW for which it was intended not work with public command.
Should adapt this event to work.
LOGs OF ERROR :
| Quote: | | RAW 303: ariel.chathispano.com, mybotnick : |
To be well, this log should say:
| Quote: | | RAW 303: ariel.chathispano.com, nick |
Example:
Suppose that the only nickname I have in the TXT file is Roger.
<oper> !ison
<log in partyline> RAW 303: ariel.chathispano.com, Roger
Then, also fails this line was intended to 'bind msg event', I guess.
| Quote: | # scan out the botnick, nick of requester and other response.
if {[scan $arg "%s :%s %\[^\n\]" bot nick response] != 3 } { |
Tcl error [ison:raw]: can't read "response": no such variable
SUMMARY: I need to adapt this TCL that was intended to 'bind msg' to work with me 'bind pub'. _________________ 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: Wed Apr 22, 2015 11:38 pm Post subject: |
|
|
Congratulations on your efforts.
Regarding the
while
loop that you used:
I suppose you can use a while loop, but that isn't how I would do it.
(Others may differ - let's hope that somebody else comes along and comments here too. )
When working with a list like that, I tend to use a
foreach
loop to iterate through each element.
I experimented with it like this:
| Code: |
foreach n $lines {
putserv "ison $n"
}
|
and discovered that the bot was buffering and queuing sending the command to the server like this:
ison nick1 nick2
and discovered that wouldn't work.
Perhaps that is why you tried to introduce a delay with a utimer?
Here is how I did it:
| Code: |
set x 1
foreach n $lines {
utimer $x [list putserv "ison $n"]
incr x 3
}
|
and on the couple tests I ran, it seems to work.
I didn't try it with a long list of nicks though. Only a couple.
About the raw binds:
Did you look up raw 461? It would seem that you won't even need it, due to what you are trying to do. Therefore, I would remove that bind.
I am not good with using the scan command. If you want to use scan, then perhaps someone else will come along to discuss that with you.
The return from ISON that triggers a raw bind 303 can be parsed using a different method though.
Like this:
| Code: |
bind RAW - 303 ison:raw
proc ison:raw { server keyword text } {
global canal_admin
set response [lindex [split $text : ] 1]
set response [string trim $response]
if {$response ne ""} {
putserv "privmsg $canal_admin :$response is online"
}
}
|
( I can't stand to use
arg
as a variable name. It looks too much like
args
for me. Usually, I use
text
for that variable name. )
The above will not have the bot say anything, if the user is not online.
It would be easy to have it say something, if you were just doing one
ISON command at a time, as in a pub command by a user.
But doing a list of them, and due to the way ISON responds without including the nick that it checked, does not make it easy to do without possibility for confusion. Perhaps someone else will have ideas for you on this.
I hope this helps. _________________ 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: Fri Apr 24, 2015 1:23 pm Post subject: |
|
|
Thanks willyw for their important help and advice.
I found another TCL is more complete than the last.
All I could not fix, was to store information, in different lines of txt file.
This stuff stored all nicks on line 1 of the file.
I have not come to understand how it interacts nlist list with the file nlist.txt so that it is stored that list on line 1 of the file.
I need every nick is stored on a separate line, because this TCL, I'll join with another, to work that way.
All attempts that I failed, because by modifying some of the code, another did not return me the expected results.
Perhaps someone with more knowledge and experience can make each nick is stored in each of the lines of txt file.
| Code: | ## File, where the list of the !ison-ed users are stored.
set filename "nlist.txt"
# Channel to whom the stuff goes.
set nchan "#channel"
# File exits ? if no then created!
if {![file exists $filename]} {
set fh [open $filename w]
puts -nonewline $fh ""
close $fh
}
## Don't change anything below, unless you know what you are doing!
# glob vars
set tell "notell"
set online ""
### raw 303 (ISON)
bind raw - 303 online:raw
### raw 325 (NS Id)
bind raw - 325 whois:idented
proc whois:idented {* 325 arg} {
global nchan
putserv "INVITE [lindex $arg 1] $nchan"
}
## ison is triggered
proc online:raw {* 303 arg} {
global online nchan tell
set nlist [getinfo]
string tolower $nlist
set arg [string trimleft [lrange $arg 1 end] ":"]
set arg [charfilter $arg]
if {$arg == ""} {
set online1 $online
if {$tell == "tell"} {
puthelp "PRIVMSG $nchan :Noone's online."
set tell "notell"
}
unset online
set online [qonreport 1 $arg $online1]
set quitted [qonreport 0 $online1 $online]
set quitted [charfilter $quitted]
set quitted [removespaces $quitted]
if {$quitted == ""} {
return
}
putserv "PRIVMSG $nchan: $quitted offline."
set online ""
} else {
if {$tell == "tell"} {
set arg [removespaces $arg]
set onchan [onlineon $arg]
set tell "notell"
set online $arg
puthelp "PRIVMSG $nchan :Online: $arg"
puthelp "PRIVMSG $nchan :Online total [llength $arg] of [llength $nlist]."
puthelp "PRIVMSG $nchan :On $nchan: [llength $onchan] of [llength $arg] online."
return
}
if {$online == ""} {
set arg [removespaces $arg]
set onchan [onlineon $arg]
set online $arg
puthelp "PRIVMSG $nchan :Online: $arg"
puthelp "PRIVMSG $nchan :Online total [llength $arg] of [llength $nlist]."
puthelp "PRIVMSG $nchan :On $nchan: [llength $onchan] of [llength $arg] online."
return
}
set foo [qonreport 0 $arg $online]
if {$foo != ""} {
set foo [charfilter $foo]
set foo [removespaces $foo]
set onchan [onlineon $arg]
append online " $foo"
puthelp "PRIVMSG $nchan :Online: $foo"
puthelp "PRIVMSG $nchan :Online total [llength $arg] of [llength $nlist]."
puthelp "PRIVMSG $nchan :On $nchan: [llength $onchan] of [llength $arg] online."
}
set online1 $online
unset online
set online [qonreport 1 $arg $online1]
set quitted [qonreport 0 $online1 $online]
set quitted [charfilter $quitted]
set quitted [removespaces $quitted]
if {$quitted == ""} {
return
}
putserv "PRIVMSG $nchan :$quitted offline."
}
}
### !ison
bind pub n !ison ison:pub
proc ison:pub {nick host hand chan arg} {
global nchan tell
if {[string tolower $chan] != [string tolower $nchan]} {
return
}
set tell "tell"
set nlist "[getinfo]"
putserv "ISON :$nlist"
}
### !addison <nickname(s)>
bind pub n !addison ison:addison
proc ison:addison {nick host hand chan arg} {
global nchan
if {[string tolower $chan] != [string tolower $nchan]} {
return
}
if {[lindex $arg 0] == ""} {
putserv "PRIVMSG $chan :$nick: Usage !addison <nickname(s)>"
return
}
set nlist [getinfo]
set dontsay [dupZZ $nlist $arg 0]
if {$dontsay == ""} {
set count [expr [llength $arg] + [llength $nlist]]
set arg [charfilter $arg]
set arg [removespaces $arg]
putserv "PRIVMSG $chan :$nick: Done. Successfully added $arg. Total ($count)."
writetof "$nlist $arg"
set tell "tell"
putserv "ISON :$nlist"
} else {
set dontsay [removespaces $dontsay]
set dontsay [charfilter $dontsay]
putserv "PRIVMSG $chan :There is a duplicate :$dontsay"
set nlist [getinfo]
set list ""
foreach bla $arg {
if {[lsearch $list $bla] == -1} {
lappend list $bla
}
}
set final [$nlist $list 1]
if {$final != ""} {
set count [expr [llength $final] + [llength $nlist]]
set final [removespaces $final]
set final [charfilter $final]
putserv "PRIVMSG $chan :$nick: Done. Successfully added $final. Total ($count)."
}
writetof "$nlist $final"
putserv "ISON :$nlist $final"
set tell "tell"
}
}
## !delison <nickname>
bind pub n !delison del_in_fd
proc del_in_fd {nick uhost hand chan arg} {
global nchan
if {[string tolower $chan] != [string tolower $nchan]} {
return
}
if {[llength $arg] != 1} {
puthelp "NOTICE $nick :Usage: !delison <nickname|phone number>"
return 0
}
set nicknames [getinfo]
set who [lindex $arg 0]
set who [charfilter $who]
if {[lsearch -exact $nicknames [lindex $arg 0]] == -1} {
puthelp "NOTICE $nick :Nickname $who not found in the database!"
return 0
}
regsub -all "\\\m$who\\\M" $nicknames "" nicknames
regsub -all {\s+} $nicknames { } nicknames
writetof $nicknames
puthelp "NOTICE $nick :Nickname $who erased from the database!"
}
## !list [nickname]
bind pub n !list list_out_of_fd
proc list_out_of_fd {nick uhost hand chan arg} {
global nchan
if {[string tolower $chan] != [string tolower $nchan]} {
return
}
if {[llength $arg] == 0} {
set nicknames [getinfo]
set nicknames [charfilter $nicknames]
set nicknames [removespaces $nicknames]
if {$nicknames == ""} {
puthelp "NOTICE $nick :No one is added in the database!"
} else {
puthelp "NOTICE $nick :Added in the database: $nicknames"
}
} elseif {[llength $arg] == 1} {
set nicknames [getinfo]
set nicknames [string tolower $nicknames]
if {[lsearch -exact $nicknames [lindex $arg 0]] == -1} {
puthelp "NOTICE $nick :[charfilter [lindex $arg 0]] not found in the database!"
} else {
puthelp "NOTICE $nick :[charfilter [lindex $arg 0]] is in the database!"
}
} else {
puthelp "NOTICE $nick :Usage: !list \[nickname\]"
}
}
## The proc
proc notify {} {
set nlist [getinfo]
putserv "ISON :$nlist"
if {![string match *notify* [utimers]]} { utimer 30 notify }
}
proc charfilter {x {y ""} } {
for {set i 0} {$i < [string length $x]} {incr i} {
switch -- [string index $x $i] {
"\"" {append y "\\\""}
"\\" {append y "\\\\"}
"\[" {append y "\\\["}
"\]" {append y "\\\]"}
"\}" {append y "\\\}"}
"\{" {append y "\\\{"}
default {append y [string index $x $i]}
}
}
return $y
}
proc getinfo {} {
global filename
set file [open $filename r]
set nlist ""
while {![eof $file]} {
set chast [gets $file]
if {$chast != ""} {
append nlist $chast
}
}
close $file
return $nlist
}
proc removespaces {arg} {
regsub {^\s+} $arg "" arg
return $arg
}
proc onlineon {arg} {
global nchan
set onchan ""
foreach tempchar $arg {
if {![onchan $tempchar $nchan]} {
# putserv "INVITE $tempchar $nchan"
putserv "WHOIS $tempchar"
} else {
append onchan " $tempchar"
}
}
return $onchan
}
proc qonreport {how arg online} {
set aq 0
set foo ""
foreach el $arg {
foreach el1 $online {
if {$el == $el1} {
set aq 1
}
}
if {$aq == $how} {
append foo " $el"
}
set aq 0
}
return $foo
}
proc writetof {what} {
global filename
set fh [open $filename w]
puts $fh $what
close $fh
}
proc dupZZ {where what how} {
set dontsay ""
foreach el1 $what {
if {[lsearch -exact $where $el1] != -1} {
if {$how == 0} {
append dontsay " $el1"
}
} else {
if {$how == 1} {
append dontsay " $el1"
}
}
}
return $dontsay
}
if {![string match *notify* [utimers]]} { utimer 30 notify }
putlog "ISON TCL by IRCHelp.UniBG.Net+LHG Crew ++/++ Counter by V1p3r#TCL Loaded !!!" |
EDIT:
At least, make the list of nicks look like this:
at this time are as follows:
FINAL EDIT:
I fixed the code, adapting my previous TCL to the latter.
I also eliminated the RAW303 (I coudn't utility).
I removed the comment in the line 6 olinenon procedure and removed the WHOIS that no longer will use. _________________ 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
|
|