-1

好的,所以我学习 ruby​​ 并想为 kik https://dev.kik.com创建一个机器人,我只是不明白出了什么问题。

这是代码

require 'HTTParty'
require 'base64'
require 'json'

bot_name = #bot_name
api_key = #api_key
message = Message.new(self)

HTTParty.post('https://api.kik.com/v1/config',
headers: {
  'Content-Type' => 'application/json',
  'Authorization' => "#{bot_name}:#{api_key}",
},
 body: {
   "manuallySendReadReceipts" => false,
   "receiveReadReceipts" => true,
   "receiveDeliveryReceipts" => true,
   "receiveIsTyping" => true,
   message: [
   {
    body: message,
    to: user_name,
    type: 'text',
    chatId: chat_id
   }
  ],
  debug_output: $stdout
 }
)

这是错误:

kikBot.rb:7:in `<main>': uninitialized constant Message (NameError)

大部分代码是通过引用这个gem创建的

有没有办法在本地测试它并让它打印出一些“连接成功”之类的东西。

4

1 回答 1

0

错误消息说。uninitialized constant Massage,而带有错误的行告诉我们模型名为Message.

似乎您的代码库中某处有错字。在您的代码库中搜索Massage并将其替换为Message.

于 2016-07-23T05:56:41.133 回答