Module: Creates

Defined in:
lib/create.rb

Instance Method Summary collapse

Instance Method Details

#created(noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/create.rb', line 2

def created noteContent, visibility = "public", localOnly = false, cw = ""
  instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
  # Visibility: public, home, followers, specified
  postJSON = <<~JSON
{
"visibility": "#{visibility}",
"visibleUserIds": [],
"cw": "#{cw}",
"localOnly": #{localOnly},
"reactionAcceptance": null,
"noExtractMentions": false,
"noExtractHashtags": false,
"noExtractEmojis": false,
"replyId": null,
"renoteId": null,
"channelId": null,
"text": "#{noteContent}"
}
JSON

  response = HTTParty.post(
    instance,
    body: postJSON,
    headers: { 
      'Content-Type' => 'application/json',
      "Authorization" => "Bearer #{Misskey.auth.token}"
    }
  )
  if Misskey.debug.debugging
    puts postJSON
    puts response
  end

  def reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
    instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
    # Visibility: public, home, followers, specified
    postJSON = <<~JSON
{
"visibility": "#{visibility}",
"visibleUserIds": [],
"cw": "#{cw}",
"localOnly": #{localOnly},
"reactionAcceptance": null,
"noExtractMentions": false,
"noExtractHashtags": false,
"noExtractEmojis": false,
"replyId": #{replyId},
"renoteId": null,
"channelId": null,
"text": "#{noteContent}"
}
JSON

    response = HTTParty.post(
      instance,
      body: postJSON,
      headers: { 
        'Content-Type' => 'application/json',
        "Authorization" => "Bearer #{Misskey.auth.token}"
      }
    )
    if Misskey.debug.debugging
      puts postJSON
      puts response
    end
  end
end

#reply(replyId, noteContent, visibility = "public", localOnly = false, cw = "") ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/create.rb', line 35

def reply replyId, noteContent, visibility = "public", localOnly = false, cw = ""
  instance = "https://#{Misskey.auth.instanceURI}/api/notes/create"
  # Visibility: public, home, followers, specified
  postJSON = <<~JSON
{
"visibility": "#{visibility}",
"visibleUserIds": [],
"cw": "#{cw}",
"localOnly": #{localOnly},
"reactionAcceptance": null,
"noExtractMentions": false,
"noExtractHashtags": false,
"noExtractEmojis": false,
"replyId": #{replyId},
"renoteId": null,
"channelId": null,
"text": "#{noteContent}"
}
JSON

  response = HTTParty.post(
    instance,
    body: postJSON,
    headers: { 
      'Content-Type' => 'application/json',
      "Authorization" => "Bearer #{Misskey.auth.token}"
    }
  )
  if Misskey.debug.debugging
    puts postJSON
    puts response
  end
end