mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2008
Posts: 2
T
TheOner Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Oct 2008
Posts: 2
Hi,
I've got this little nut to crack. One channel where i am, has newsbot. Always when news are coming, it says "News!" and 4 next lines are: News topic, Group, snippet from news, and link to news.

What i want to do? If news topic contains specified things, i wanted to say it to my other channel.

02:10:00 <NewsBot> News!
02:10:00 <NewsBot> Topic: NASA uses mIRC!
02:10:00 <NewsBot> Group: Comedy
02:10:00 <NewsBot> Snippet: It has proved that nasa uses mIRC...
02:10:00 <NewsBot> Link: http://this.is.just.example.com

Basically it would be enough if i could catch topic and link to news. So if topic contains word "NASA", i would say to other channel <TheOner> News! NASA uses mIRC! - http://...

I got this far ( whistle ), and started to think that how i would get next 4 lines to variables or array? So i could check if topic contains specified word etc. etc.

ON *:TEXT:News!:*: { if ($nick = NewsBot) { } }

Joined: Feb 2004
Posts: 206
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Feb 2004
Posts: 206
As an initial thought, copy all Newsbot Text to a custom window (On TEXT etc). You can then parse the last 5 lines (or groups of 5 lines) to extract the information you want at a time of your convenience (e.g. ON text Link).

Another option is to use some global variables, and have a series of on text commands:

On *:text:Topic*:*: { if ($nick = NewsBot) { } }
On *:text:Group*:*: { if ($nick = NewsBot) { } }
On *:text:Snippet*:*: { if ($nick = NewsBot) { } }
On *:text:Link*:*: { if ($nick = NewsBot) { } }

each series of commands could build on the previous global variable, if you are confident that the text will always come in the same order.

There may be other methods?

Cheers,

DK


Darwin_Koala

Junior Brat, In-no-cent(r)(tm) and original source of DK-itis!
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Do you want the script to determine which messages should be shown in your channel (keyword matches), or are you going to read them yourself and decide which ones to use? If you are going to use keywords, which of the 4 lines do you want to be able to match in?

-genius_at_work

Joined: Nov 2006
Posts: 9
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: Nov 2006
Posts: 9
Originally Posted By: genius_at_work
Do you want the script to determine which messages should be shown in your channel (keyword matches), or are you going to read them yourself and decide which ones to use? If you are going to use keywords, which of the 4 lines do you want to be able to match in?

-genius_at_work


Hmm. Im sorry cause my english isn't so good cool . But absolutely automated script what does all. If NewsBot's topic-line contains specified word, example "NASA". Then script would automatically react and say to other channel like /say #channel News! [news topic here] - [news link here].

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Here is a code you can try:


Code:

on *:TEXT:*:#channel:{
  if ($nick != NewsBot) return

  if ($1 == news!) {
    unset %news.*
    set -u30 %news.rec 1
    set -u30 %news.show 0
    return
  }
  elseif ($1 == Topic:) { 
    set -u30 %news.topic $1- 
    ;;; Check Topic below this line vvvvv

    if (NASA isin $2-) set -u30 %news.show 1

    ;;; Check Topic above this line ^^^^^
  }
  elseif ($1 == Group:) { 
    set -u30 %news.group $1- 
    ;;; Check Group below this line vvvvv

    if ($istok(science space nasa,$2,32)) set -u30 %news.show 1

    ;;; Check Group above this line ^^^^^
  }
  elseif ($1 == Snippet:) { 
    set -u30 %news.snippet $1- 
    ;;; Check Snippet below this line vvvvv

    if (NASA isin $2-) set -u30 %news.show 1

    ;;; Check Snippet above this line ^^^^^
  }
  elseif ($1 == Link:) { 
    set -u30 %news.link $1-
    ;;; Check Link below this line vvvvv

    if (www.nasa.com isin $2-) set -u30 %news.show 1

    ;;; Check Link above this line ^^^^^
  }

  if (%news.show) {
    msg #mychannel News!
    msg #mychannel %news.topic
    msg #mychannel %news.group
    msg #mychannel %news.snippet
    msg #mychannel %news.link

    unset %news.*
  }
}



You need to change #channel, #mychannel, NewsBot as necessary.

Put your keyword checks between the

;;; Check _____ below this line vvvvv

and

;;; Check _____ above this line ^^^^^

lines in each section (Topic, Group, Snippet, Link). Samples are already there for your NASA example.

-genius_at_work

Joined: Nov 2006
Posts: 9
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: Nov 2006
Posts: 9
Big thanks for your help. I tried this code, but it works half. I removed all IF:s but this, in topic: "if (NASA isin $2-) set -u30 %news.show 1". Cause it is enough, that topic contains specified word and then it would paste topic, group, snippet, link.

First of all, topic didn't need to match to anything that it started to msg channel. It says all news, even there is (NASA isin $2-).

Secondly, msg acts weirdly too. I came to irc with other client and simulated this situation.

(20:17:55) <NewsBot> News!
(20:17:55) <NewsBot> Topic: NASA test new
(20:17:55) <NewsBot> Group: Test
(20:17:55) <NewsBot> Snippet: gasgiagagag
(20:17:55) <NewsBot> Link: http://www.test.com

And script outputs:
(20:17:55) <TheOner> News!
(20:17:55) <TheOner> Topic: NASA test new
(20:17:55) <TheOner> Group: Test
(20:17:55) <TheOner> News!
(20:17:55) <TheOner> Topic: NASA test new
(20:17:55) <TheOner> Group: Test
(20:17:55) <TheOner> Snippet: gasgiagagag
(20:17:55) <TheOner> News!
(20:17:55) <TheOner> Topic: NASA test new
(20:17:55) <TheOner> Group: Test
(20:17:55) <TheOner> Snippet: gasgiagagag
(20:17:55) <TheOner> News!
(20:17:55) <TheOner> Topic: NASA test new
(20:17:55) <TheOner> Group: Test
(20:17:55) <TheOner> Snippet: gasgiagagag
(20:17:55) <TheOner> Link: http://www.test.com


Last edited by Jammaez; 06/10/08 05:32 PM.
Joined: Nov 2006
Posts: 9
J
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
J
Joined: Nov 2006
Posts: 9
I fixed it my self. I made IF condition what checks if news.topic etc. variables are set. Now it says it only once.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
That's what I get for writing code at 630 am. crazy

-genius_at_work

Joined: Oct 2008
Posts: 2
T
TheOner Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
T
Joined: Oct 2008
Posts: 2
Originally Posted By: genius_at_work
That's what I get for writing code at 630 am. crazy

-genius_at_work


Hehe smile But big thanks to you! I noticed new problem now. Cause channels are on different servers where to get news and where to say them. Now it tries to say them on "newsbot server" and of course status windows is full of "No such nick/channel".

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
You can use the /scid or /scon commands to send messages from one server to the other. For example, if you always connect to the 'newsbot server' first and the 'other server' second, something like this might work for you:

Code:

/scon 2
/msg #chan blah
/msg #chan blah
/msg #chan blah
/scon -r



-genius_at_work


Link Copied to Clipboard