Added channel posting
This commit is contained in:
parent
51a798ea3e
commit
f9fbbbd225
@ -313,6 +313,13 @@ class APnutI
|
||||
return $this->makeRequest($method, $end_point, $parameters, $content_type);
|
||||
}
|
||||
|
||||
public function postJson(
|
||||
string $end_point,
|
||||
array $parameters,
|
||||
): array {
|
||||
return $this->post($end_point, $parameters, 'application/json');
|
||||
}
|
||||
|
||||
public function get(
|
||||
string $end_point,
|
||||
array $parameters = [],
|
||||
|
@ -80,6 +80,44 @@ class Channel
|
||||
}
|
||||
}
|
||||
|
||||
#TODO_ return message object instead of response
|
||||
public function postMessage(string $text, array $raw = [], array $parameters = [])
|
||||
{
|
||||
$this->api->logger->debug('Creating channel message');
|
||||
$params = [
|
||||
'text' => $text,
|
||||
'raw' => $raw
|
||||
];
|
||||
$params = array_merge($params, $parameters);
|
||||
$this->api->logger->debug(json_encode($params));
|
||||
$resp = $this->api->postJson('/channels/'.$this->id.'/messages', $params);
|
||||
$this->api->logger->debug(json_encode($resp));
|
||||
return $resp;
|
||||
}
|
||||
|
||||
public static function makeChannelInviteRaw(int $channel_id)
|
||||
{
|
||||
return [
|
||||
'io.pnut.core.channel.invite' => [
|
||||
[
|
||||
'channel_id' => $channel_id
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public static function makeBroadcastNoticeRaw(int $post_id)
|
||||
{
|
||||
return [
|
||||
'net.patter-app.broadcast' => [
|
||||
[
|
||||
'id' => $post_id,
|
||||
'url' => 'https://posts.pnut.io/'.$post_id
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
$str = '';
|
||||
|
@ -192,15 +192,6 @@ class Poll
|
||||
|
||||
public static function makePollNoticeRaw(int $poll_id, string $poll_token)
|
||||
{
|
||||
/*return [
|
||||
'type' => 'io.pnut.core.poll-notice',
|
||||
'value' => [
|
||||
'+io.pnut.core.poll' => [
|
||||
'poll_id' => $poll_id,
|
||||
'poll_token' => $poll_token
|
||||
]
|
||||
]
|
||||
];*/
|
||||
return [
|
||||
'io.pnut.core.poll-notice' => [
|
||||
[
|
||||
|
Loading…
Reference in New Issue
Block a user