|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
Hi, it's me again. I saw a script once wich I really liked, but I never got my hands on it, heres what it could do: Lets say your an OP on a channel and you got some news you would like others to see, you could type !addnews texthere and then if a user typed !news he would see the news added by the OP containing the date of when the news was added, also, if I remember correct, you could get a whole list of news, and each news would have a number, dont know if this kind of script is around on this site, but I would really like some help with this.
ps. I hope I explained this okay.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:text:!addnews*:#:{
if ($nick isop $chan) {
.write news.txt $ctime $2-
}
}
on *:text:!news*:*:{
if $2 !isnum $+(1-,$lines(news.txt)) {
.msg $nick There are $lines(news.txt) news items
.play $nick news.txt
}
else play -l $+ $2 $nick news.txt
}
This is an extremely simple version of what could be an extremely complex script. Ops can use !addnews <news item> Usage of !news will give all of the news, or !news <number> will give that particular item. If there are a lot of items and people use !news, then there might be a delay in sending the information
|
|
|
|
Joined: Mar 2005
Posts: 212
Fjord artisan
|
Fjord artisan
Joined: Mar 2005
Posts: 212 |
depending on ho much news there is you can add a delay in the play command to prevent you from flooding or whatever
like thusly else play -l $+ $2 $nick news.txt 1000 ^1 second delay i assume you can work out the rest from here
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
Okay, im trying it out and thanks, but after I added a news, I get this: 1137654993 test
What are these numbers?
Ohh, and how would I go about so it all is showing in a notice? And is there a way of adding the date of wich the news was added and the nick of the one who added it? sorry if im asking alot.
Last edited by starpossen; 19/01/06 07:22 AM.
|
|
|
|
Joined: Aug 2005
Posts: 525
Fjord artisan
|
Fjord artisan
Joined: Aug 2005
Posts: 525 |
You can make play use notice instead of msg by applying the -n switch.
/play -n $nick news.txt
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
The numbers are the timestamp that was recorded using $ctime. From the help file: $ctime returns total number of seconds elapsed since 00:00:00 GMT, January 1, 1970 based on your system time. Sorry about that. Here's an updated code, since I was unable to edit the original. If you don't like the format of the datestamp that is used by default, you can specify the format using the same parameters used in $asctime /help $asctime for more information on *:text:!addnews*:#:{
if ($nick isop $chan) {
.write news.txt $date $nick $2-
}
}
on *:text:!news*:*:{
if $2 !isnum $+(1-,$lines(news.txt)) {
.msg $nick There are $lines(news.txt) news items
.play -n $nick news.txt
}
else play -nl $+ $2 $nick news.txt
}
on *:text:!delnews*:*:{
if $2 !isnum $+(1-,$lines(news.txt)) {
.msg $nick News Item $2 not found
}
else .write -dl $+ $2
}
Last edited by RusselB; 19/01/06 09:23 AM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Neutron Star: The /play command defaults to a 1 second delay if no number is entered for a delay time. /play c:\text\poem.txt
This plays the file poem.txt to the current window, which must be a query or channel window, with a default delay of 1000 milliseconds, ie. 1 second. Empty lines are treated as a delay.
|
|
|
|
Joined: Mar 2005
Posts: 420
Fjord artisan
|
Fjord artisan
Joined: Mar 2005
Posts: 420 |
Here's a news bot I made before for someone: On *:START: {
hmake news 100
if ( $isfile(news.dat) ) hload news news.dat
}
On *:EXIT: hsave -o news news.dat
On *:TEXT:!*:#: {
if ($1 == !news) {
if ( $hget(news,$+($network,.,$chan)) ) {
var %h = $v1
if ($2) {
if ($2 isnum $+(1-,$numtok(%h,157)) ) {
notice $nick News $+($chr(35),$2,:) $gettok(%h,$2,157)
}
else notice $nick Syntax: !news [number] (Current Total News is: $numtok(%h,157) $+ )
}
else notice $nick [Latest] News $+($chr(35),$numtok(%h,157),:) $gettok(%h,$numtok(%h,157),157)
}
else notice $nick No news is set for $chan $+ .
}
elseif ($1 == !totalnews) notice $nick Total news set for $chan is: $numtok($hget(news,$+($network,.,$chan)),157)
}
on *:TEXT:!*:?: {
if ($1 == !addnews) {
if ($nick isop $2) {
if ($3) {
hadd -m news $+($network,.,$2) $addtok($hget(news,$+($network,.,$2)), $2- < $+ $nick - $fulldate $+ >, 157)
notice $nick ** Added news for $2 $+ .
}
else notice $nick Syntax: /msg $me !addnews <#Channel> <news>
close -m $nick
}
}
elseif ($1 == !delnews) {
if ($nick isop $2) {
if ( $hget(news,$+($network,.,$2)) ) {
var %g = $v1
if ($3) {
if ($3 isnum $+(1-,$numtok(%g,157)) ) {
hadd -m news $+($network,.,$2) $deltok(%g,$3,157)
notice $nick ** Deleted News $+($chr(35),$3) for $2 $+ .
}
else notice $nick News $+($chr(35),$3) does not exist.
}
else notice $nick Syntax: !delnews <#Channel> <number>
}
else notice $nick No news is set for $2 $+ .
close -m $nick
}
}
}
on !*:JOIN:#: $+(.timernews,.,$cid,.,$chan,.,$nick) 1 5 if ( $nick ison $chan ) .notice $nick Hi $nick $+ , Welcome to $chan $+ . $!iif( $!hget(news,$+( $network ,., $chan )), I have $!numtok($v1,157) news stored. Type "!news <number>" to view them.)
Commands: For Ops: /msg botname !addnews <#channel> <news> /msg botname !delnews <#channel> <news_number> Everyone: !news [number] - if no number is given, will give latest news. !totalnews -EDIT- -had to fix a small bug
Last edited by xDaeMoN; 19/01/06 07:56 AM.
If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
Guys, this is really looking good, and I also had a look at the help for $asctime and I added time to the date, it's really starting to look good, now for one more feature I dont know if this would be a tricky one, but is it possible to add an delete command, like: !del 1 where 1 offcourse is the number of the news I would like to delete. That would be awsome. Once again, thank you for your quick replys.
EDIT: xDaeMoN , hehe you postet almost at the same time as me, nice looking script you got there, ill have a look at it.
EDIT2: RusselB that script you postet, is there any way to add a delete feature?
Last edited by starpossen; 19/01/06 09:01 AM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
!delnews command added to code via edit
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
When I try to use the !delnews 1 my bot shows me this * /write: insufficient parameters (line 33, script3.mrc) Why is that?
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Simply because I wasn't paying attention. Corrected code follows, as I was unable to edit due to the amount of time that had passed. on *:text:!addnews*:#:{
if ($nick isop $chan) {
.write news.txt $date $nick $2-
}
}
on *:text:!news*:*:{
if $2 !isnum $+(1-,$lines(news.txt)) {
.msg $nick There are $lines(news.txt) news items
.play -n $nick news.txt
}
else play -nl $+ $2 $nick news.txt
}
on *:text:!delnews*:*:{
if $2 !isnum $+(1-,$lines(news.txt)) {
.msg $nick News Item $2 not found
}
else .write -dl $+ $2 news.txt
}
|
|
|
|
Joined: Oct 2005
Posts: 98
Babel fish
|
OP
Babel fish
Joined: Oct 2005
Posts: 98 |
It works great thanks alot guys, now for my final question, is it possible to a number, I mean, if you type !news and there is say 5 news, and it then would add a number infront of each news, depending on wich got added first.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
With mine, not easily. Looks like xDaeMoN already has that included in his code.
|
|
|
|
|