| 245 | | ret = api("statuses/update", {"status" => message, "in_reply_to_status_id" => rid, "keyword" => channel}) |
| | 245 | if @typo |
| | 246 | log "typo mode. requesting..." |
| | 247 | message.gsub!(/\\n/, "\n") |
| | 248 | file = Net::HTTP.get(URI("http://lab.lowreal.net/test/haiku.rb/?text=" + URI.escape(message))) |
| | 249 | ret = api("statuses/update", {"file" => file, "in_reply_to_status_id" => rid, "keyword" => channel}) |
| | 250 | else |
| | 251 | ret = api("statuses/update", {"status" => message, "in_reply_to_status_id" => rid, "keyword" => channel}) |
| | 252 | end |
| 556 | | req.body = uri.query |
| | 566 | if q["file"] |
| | 567 | boundary = (rand(0x1_00_00_00_00_00) + 0x1_00_00_00_00_00).to_s(16) |
| | 568 | @log.info boundary |
| | 569 | req["content-type"] = "multipart/form-data; boundary=#{boundary}" |
| | 570 | |
| | 571 | body = "" |
| | 572 | q.each do |k, v| |
| | 573 | body << "--#{boundary}\r\n" |
| | 574 | if k == "file" |
| | 575 | body << "Content-Disposition: form-data; name=\"#{k}\"; filename=\"temp.png\";\r\n" |
| | 576 | body << "Content-Transfer-Encoding: binary\r\n" |
| | 577 | body << "Content-Type: image/png\r\n" |
| | 578 | else |
| | 579 | body << "Content-Disposition: form-data; name=\"#{k}\";\r\n" |
| | 580 | end |
| | 581 | body << "\r\n" |
| | 582 | body << v.to_s |
| | 583 | body << "\r\n" |
| | 584 | end |
| | 585 | body << "--#{boundary}--\r\n" |
| | 586 | |
| | 587 | req.body = body |
| | 588 | uri.query = "" |
| | 589 | else |
| | 590 | req.body = uri.query |
| | 591 | end |