Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

Commit

Permalink
Merge pull request #205 from mallowlabs/id/205
Browse files Browse the repository at this point in the history
misc/bot is too old
  • Loading branch information
mallowlabs committed Nov 24, 2014
2 parents 961c16c + cf39813 commit dea22b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 40 deletions.
32 changes: 0 additions & 32 deletions misc/bot/simple-ssl.rb

This file was deleted.

23 changes: 15 additions & 8 deletions misc/bot/simple.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
#! /user/bin/env ruby
#!/user/bin/env ruby
# -*- mode:ruby; coding:utf-8 -*-

# ------------------------------
# example for bot
# ------------------------------

# Get from http://$AS_ROOT/account/index
ApiKey = "YOUR_API_KEY"
API_KEY = "YOUR_API_KEY"

# EntryPoint
EntryPoint = "http://localhost:3000/api/v1"
ENTRY_POINT = "http://localhost:3000/api/v1"

# ------------------------------
require 'net/http'
require 'net/https'

if ARGV.size != 2 then
puts "#{$0} <room_id> <message>"
exit 0
end

room_id, message = *ARGV
uri = URI(EntryPoint)
uri = URI(ENTRY_POINT)

Net::HTTP.start(uri.host, uri.port) do| http |
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |h|
# post message
p http.post(uri.path + "/message",
"room_id=#{room_id}&message=#{message}&api_key=#{ApiKey}")
p h.post(uri.path + "/message", URI.encode_www_form({
room_id: room_id,
api_key: API_KEY,
message: message
}))
end

0 comments on commit dea22b9

Please sign in to comment.