Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

FOSS node.js Shiichan post bot

Name: Anonymous 2013-08-16 23:31

var http = require('http')
var querystring = require('querystring')
function PostData(data, handler) {
  var string = ""
  http.request({
    host:    "dis.4chan.org",
    path:    "/post",
    method:  "POST",
    headers: {
      'content-type': "application/x-www-form-urlencoded",
      'content-length': data.length
    }
  }, function(res) {
    console.log('STATUS: ' + res.statusCode)
    console.log('HEADERS: ' + JSON.stringify(res.headers))
    res.setEncoding('utf8')
  }).on('response', function(response){
    response.on('data', function(chunk){ string += chunk })
    response.on('end', function(){ handler(string) })
  }).end(data)
}
function MakeMessage(data) {
  return querystring.stringify({
    bbs:      data.board,
    id:       data.thread,
    shiichan: "proper2",
    kotehan:  data.name,
    meiru:    data.email,
    com:      data.message,
    email:    "'"
  })
}
function PostMessage(data, handler) {
  PostData(MakeMessage(data), handler)
}
function TestMessage(data, handler) {
  console.log(MakeMessage(data))
  handler("")
}
function GetData(path, handler) {
  var string = ""
  http.get({host: "dis.4chan.org", path: path}, function(res) {
    console.log('STATUS: ' + res.statusCode)
    console.log('HEADERS: ' + JSON.stringify(res.headers))
    res.setEncoding('utf8')
  }).on('response', function(response){
    response.on('data', function(chunk){ string += chunk })
    response.on('end', function(){ handler(string) })
  })
}
function GetBoardData(board, handler) {
  GetData("/" + board + "/subject.txt", function(s){
    handler(function(){
      var o = s.split("\n").map(function(s){
      var a = s.split(/<>/)
      return {
        subject: a[0],
        op:      a[1],
        icon:    a[2],
        id:      a[3],
        last:    a[4],
        lp:      a[5],
        endtime: a[6],
      }})
      o.pop()
      return o
    }())
  })
}
function GetThreadData(board, thread, handler) {
  GetData("/json/" + board + "/" + thread, function(s){
    handler(JSON.parse(s))
  })
}
function ReadyForDubs(t) {
    var s = t.last.toString()
    var n = s.length
    if (n < 2) return false
    return ((s[n-1] == '9' && s[n-2] == '9') || +s[n-2] == s[n-1]+1)
}
function HasDubs(t) {
    var s = t.last.toString()
    var n = s.length
    if (n < 2) return false
    return (s[n-2] == s[n-1])
}
function MakePostWhere(poster, board, pred, datasrc) {
  GetBoardData(board, function(descr){
    function call(i){
      if (pred(descr[i])) {
        PostMessage(datasrc({
          board: board,
          thread: descr[i].id
        }, descr[i]), function(res){
          if (i + 1 < descr.length) setTimeout(call, 4700, i + 1)
        })
      } else if (i + 1 < descr.length) setImmediate(call, i + 1)
    }
    setImmediate(call, 0)
  })
}
MakePostWhere(PostMessage, "prog", HasDubs, function(p, t){
  p.message = ">>" + t.last + "\nNice dubs, bro!"
  return p
})

Name: 1 2013-08-16 23:34

WTFPL license of course.

Name: Anonymous 2013-08-16 23:35

Excellent!

Name: 1 2013-08-16 23:49

        PostMessage(datasrc({
That line should be:
        poster(datasrc({
My bot made the "Nice dubs, bro!" message in post >>11 here:
http://dis.4chan.org/read/prog/1376315588

Name: Anonymous 2013-08-17 2:06

I could see this leading to a nice chat bot thread.

Name: Anonymous 2013-08-17 2:27

This is, like, one line of shell script with wget. Stop over engineering things.

Name: Anonymous 2013-08-17 2:29

>>6
umena curl?

Name: Anonymous 2013-08-17 2:34

>>7
I meant what I wrote and wrote what I meant. curl is for losers.

Name: Anonymous 2013-08-17 4:18

>>8
ok

Name: Anonymous 2013-08-17 6:45

U MENA WPUT

Name: Anonymous 2013-08-17 6:50

WPUT (1510 AM) is a radio station broadcasting a sports talk format. Licensed to Brewster, New York, USA, the station is owned by Cumulus Media and features programming from CBS Sports Radio and Motor Racing Network.[1]

In December 2012, WPUT and WINE (AM) became CBS Sports Radio's 940SportsRadio[2]

Name: Anonymous 2013-08-17 8:16

Name: Anonymous 2013-08-17 10:38

What the fuck, >>1? My bot is like 20 lines of FIOC.

Name: Anonymous 2013-08-17 11:47

Hey /b/uddy, you forgot these:

                           )};()
                    }};){};();
            }}();;())}
        }};}():)}
    []};():()]
 }};}}};}};}}}};};;
}};

Name: Anonymous 2013-08-17 21:44

Node dot jizz

Name: Anonymous 2013-08-17 21:48

>>15
RRRrnggkkk!

Hey look, JavaScript!

Name: Anonymous 2013-08-18 17:42

dubs

Name: Anonymous 2013-08-18 17:43

>>14
Thanks!

var http = require('http')
var querystring = require('querystring')
function PostData(data, handler) {
  var string = ""
  http.request({
    host:    "dis.4chan.org",
    path:    "/post",
    method:  "POST",
    headers: {
      'content-type': "application/x-www-form-urlencoded",
      'content-length': data.length
    }
  }, function(res) {
    console.log('STATUS: ' + res.statusCode)
    console.log('HEADERS: ' + JSON.stringify(res.headers))
    res.setEncoding('utf8')
  }).on('response', function(response){
    response.on('data', function(chunk){ string += chunk })
    response.on('end', function(){ handler(string) })
  }).end(data)
}
function MakeMessage(data) {
  return querystring.stringify({
    bbs:      data.board,
    id:       data.thread,
    shiichan: "proper2",
    kotehan:  data.name,
    meiru:    data.email,
    com:      data.message,
    email:    "'"
  })
}
function PostMessage(data, handler) {
  PostData(MakeMessage(data), handler)
}
function TestMessage(data, handler) {
  console.log(MakeMessage(data))
  handler("")
}
function GetData(path, handler) {
  var string = ""
  http.get({host: "dis.4chan.org", path: path}, function(res) {
    console.log('STATUS: ' + res.statusCode)
    console.log('HEADERS: ' + JSON.stringify(res.headers))
    res.setEncoding('utf8')
  }).on('response', function(response){
    response.on('data', function(chunk){ string += chunk })
    response.on('end', function(){ handler(string) })
  })
}
function GetBoardData(board, handler) {
  GetData("/" + board + "/subject.txt", function(s){
    handler(function(){
      var o = s.split("\n").map(function(s){
      var a = s.split(/<>/)
      return {
        subject: a[0],
        op:      a[1],
        icon:    a[2],
        id:      a[3],
        last:    a[4],
        lp:      a[5],
        endtime: a[6],
      }})
      o.pop()
      return o
    }())
  })
}
function GetThreadData(board, thread, handler) {
  GetData("/json/" + board + "/" + thread, function(s){
    handler(JSON.parse(s))
  })
}
function ReadyForDubs(t) {
    var s = t.last.toString()
    var n = s.length
    if (n < 2) return false
    return ((s[n-1] == '9' && s[n-2] == '9') || +s[n-2] == s[n-1]+1)
}
function HasDubs(t) {
    var s = t.last.toString()
    var n = s.length
    if (n < 2) return false
    return (s[n-2] == s[n-1])
}
function MakePostWhere(poster, board, pred, datasrc) {
  GetBoardData(board, function(descr){
    function call(i){
      if (pred(descr[i])) {
        PostMessage(datasrc({
          board: board,
          thread: descr[i].id
        }, descr[i]), function(res){
          if (i + 1 < descr.length) setTimeout(call, 4700, i + 1)
        })
      } else if (i + 1 < descr.length) setImmediate(call, i + 1)
    }
    setImmediate(call, 0)
  })
}
MakePostWhere(PostMessage, "prog", HasDubs, function(p, t){
  p.message = ">>" + t.last + "\nNice dubs, bro!"
  return p
})
                           )};()
                    }};){};();
            }}();;())}
        }};}():)}
    []};():()]
 }};}}};}};}}}};};;
}};

Name: Anonymous 2013-08-18 17:53

not using Promises/A+

end thyself

Don't change these.
Name: Email:
Entire Thread Thread List