GitHubAdapter
in package
implements
Adapter, HandlesSlashCommands, HasAuthorInfo, SupportsDeleteMessages, SupportsEditMessages
Table of Contents
Interfaces
Constants
- EMOJI_MAP : mixed = ['👍' => '+1', '+1' => '+1', 'thumbs_up' => '+1'...
Properties
- $apiUrl : string
- $appId : string|null
- $authToken : string|null
- $botUserId : string|null
- $fileUploadConverter : FileUploadConverter
- $formatConverter : GitHubFormatConverter
- $httpClient : ClientInterface
- $installationId : string|null
- $installationIds : array<string, string>
- $installationTokenCache : array<string, array{token: string, expiresAt: int}>
- $privateKey : string|null
- $psrFactory : Psr17Factory|null
- $webhookVerifier : GitHubWebhookVerifier
Methods
- __construct() : mixed
- addReaction() : void
- channelIdFromThreadId() : string
- createResponse() : ResponseInterface|null
- decodeThreadId() : mixed
- deleteMessage() : void
- disconnect() : void
- editMessage() : SentMessage
- encodeThreadId() : string
- fetchChannelInfo() : ChannelInfo|null
- fetchMessages() : FetchResult
- fetchThread() : ThreadInfo
- getAuthorInfo() : Author
- getBotUserId() : string|null
- getFormatConverter() : FormatConverter|null
- getName() : string
- getUser() : UserInfo|null
- initialize() : void
- openDM() : string|null
- parseSlashCommand() : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
- parseWebhook() : Message
- postMessage() : SentMessage
- removeReaction() : void
- startTyping() : void
- stream() : SentMessage|null
- verifyWebhook() : ResponseInterface|null
- apiCall() : array<string|int, mixed>
- appendAttachments() : string
- base64urlEncode() : string
- deriveChannelId() : string
- exchangeInstallationToken() : array<string|int, mixed>
- generateJWT() : string
- getAuthToken() : string
- getInstallationToken() : string
- jsonResponse() : ResponseInterface
- parseIssueComment() : Message
- parseReviewComment() : Message
- renderBody() : string
Constants
EMOJI_MAP
protected
mixed
EMOJI_MAP
= ['👍' => '+1', '+1' => '+1', 'thumbs_up' => '+1', '👎' => '-1', '-1' => '-1', 'thumbs_down' => '-1', '😄' => 'laugh', 'laugh' => 'laugh', 'smile' => 'laugh', '😕' => 'confused', 'confused' => 'confused', 'thinking' => 'confused', '❤️' => 'heart', 'heart' => 'heart', 'love_eyes' => 'heart', '🎉' => 'hooray', 'hooray' => 'hooray', 'party' => 'hooray', 'confetti' => 'hooray', '🚀' => 'rocket', 'rocket' => 'rocket', '👀' => 'eyes', 'eyes' => 'eyes']
Properties
$apiUrl read-only
protected
string
$apiUrl
= 'https://api.github.com'
$appId read-only
protected
string|null
$appId
= null
$authToken read-only
protected
string|null
$authToken
= null
$botUserId
protected
string|null
$botUserId
= null
$fileUploadConverter
protected
FileUploadConverter
$fileUploadConverter
$formatConverter
protected
GitHubFormatConverter
$formatConverter
$httpClient read-only
protected
ClientInterface
$httpClient
$installationId read-only
protected
string|null
$installationId
= null
$installationIds
protected
array<string, string>
$installationIds
= []
owner/repo → installation ID
$installationTokenCache
protected
array<string, array{token: string, expiresAt: int}>
$installationTokenCache
= []
installation ID → cached token
$privateKey read-only
protected
string|null
$privateKey
= null
$psrFactory read-only
protected
Psr17Factory|null
$psrFactory
= null
$webhookVerifier
protected
GitHubWebhookVerifier
$webhookVerifier
Methods
__construct()
public
__construct(ClientInterface $httpClient, string $webhookSecret[, string|null $authToken = null ][, string $apiUrl = 'https://api.github.com' ][, string|null $appId = null ][, string|null $installationId = null ][, Psr17Factory|null $psrFactory = null ][, FileUploadConverter|null $fileUploadConverter = null ][, string|null $privateKey = null ]) : mixed
Parameters
- $httpClient : ClientInterface
- $webhookSecret : string
- $authToken : string|null = null
- $apiUrl : string = 'https://api.github.com'
- $appId : string|null = null
- $installationId : string|null = null
- $psrFactory : Psr17Factory|null = null
- $fileUploadConverter : FileUploadConverter|null = null
- $privateKey : string|null = null
addReaction()
public
addReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
- $threadId : string
- $messageId : string
- $emoji : string
channelIdFromThreadId()
public
channelIdFromThreadId(string $threadId) : string
Parameters
- $threadId : string
Return values
stringcreateResponse()
public
createResponse() : ResponseInterface|null
Return values
ResponseInterface|nulldecodeThreadId()
public
decodeThreadId(string $threadId) : mixed
Parameters
- $threadId : string
deleteMessage()
public
deleteMessage(string $threadId, string $messageId) : void
Parameters
- $threadId : string
- $messageId : string
disconnect()
public
disconnect() : void
editMessage()
public
editMessage(string $threadId, string $messageId, PostableMessage $message) : SentMessage
Parameters
- $threadId : string
- $messageId : string
- $message : PostableMessage
Return values
SentMessageencodeThreadId()
public
encodeThreadId(mixed $platformData) : string
Parameters
- $platformData : mixed
Return values
stringfetchChannelInfo()
public
fetchChannelInfo(string $channelId) : ChannelInfo|null
Parameters
- $channelId : string
Return values
ChannelInfo|nullfetchMessages()
public
fetchMessages(string $threadId[, FetchOptions|null $options = null ]) : FetchResult
Parameters
- $threadId : string
- $options : FetchOptions|null = null
Return values
FetchResultfetchThread()
public
fetchThread(string $threadId) : ThreadInfo
Parameters
- $threadId : string
Return values
ThreadInfogetAuthorInfo()
public
getAuthorInfo(Author $author) : Author
Parameters
- $author : Author
Return values
AuthorgetBotUserId()
public
getBotUserId() : string|null
Return values
string|nullgetFormatConverter()
public
getFormatConverter() : FormatConverter|null
Return values
FormatConverter|nullgetName()
public
getName() : string
Return values
stringgetUser()
public
getUser(string $userId) : UserInfo|null
Parameters
- $userId : string
Return values
UserInfo|nullinitialize()
public
initialize(Chat $chat) : void
Parameters
- $chat : Chat
openDM()
public
openDM(string $userId) : string|null
Parameters
- $userId : string
Return values
string|nullparseSlashCommand()
public
parseSlashCommand(ServerRequestInterface $request) : Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|null
Parameters
- $request : ServerRequestInterface
Return values
Author, command: string, text: string, userId: string, isBot: bool, isMe: bool, channelId: string, triggerId: ?string, raw: mixed}|nullparseWebhook()
public
parseWebhook(ServerRequestInterface $request) : Message
Parameters
- $request : ServerRequestInterface
Return values
MessagepostMessage()
public
postMessage(string $threadId, PostableMessage $message) : SentMessage
Parameters
- $threadId : string
- $message : PostableMessage
Return values
SentMessageremoveReaction()
public
removeReaction(string $threadId, string $messageId, string $emoji) : void
Parameters
- $threadId : string
- $messageId : string
- $emoji : string
startTyping()
public
startTyping(string $threadId) : void
Parameters
- $threadId : string
stream()
public
stream(string $threadId, iterable<string|int, mixed> $textStream[, array<string|int, mixed> $options = [] ]) : SentMessage|null
Parameters
- $threadId : string
- $textStream : iterable<string|int, mixed>
- $options : array<string|int, mixed> = []
Return values
SentMessage|nullverifyWebhook()
public
verifyWebhook(ServerRequestInterface $request) : ResponseInterface|null
Parameters
- $request : ServerRequestInterface
Return values
ResponseInterface|nullapiCall()
protected
apiCall(string $endpoint, array<string|int, mixed> $params[, string $method = 'POST' ][, array<string|int, mixed> $queryParams = [] ]) : array<string|int, mixed>
Parameters
- $endpoint : string
- $params : array<string|int, mixed>
- $method : string = 'POST'
- $queryParams : array<string|int, mixed> = []
Return values
array<string|int, mixed>appendAttachments()
protected
appendAttachments(string $body, PostableMessage $message) : string
Parameters
- $body : string
- $message : PostableMessage
Return values
stringbase64urlEncode()
protected
base64urlEncode(string $data) : string
Parameters
- $data : string
Return values
stringderiveChannelId()
protected
deriveChannelId(array<string|int, mixed> $payload, string $event) : string
Parameters
- $payload : array<string|int, mixed>
- $event : string
Return values
stringexchangeInstallationToken()
protected
exchangeInstallationToken(string $installationId) : array<string|int, mixed>
Parameters
- $installationId : string
Return values
array<string|int, mixed>generateJWT()
protected
generateJWT() : string
Return values
stringgetAuthToken()
protected
getAuthToken(string $owner, string $repo) : string
Parameters
- $owner : string
- $repo : string
Return values
stringgetInstallationToken()
protected
getInstallationToken(string $installationId) : string
Parameters
- $installationId : string
Return values
stringjsonResponse()
protected
jsonResponse(int $status, string $message) : ResponseInterface
Parameters
- $status : int
- $message : string
Return values
ResponseInterfaceparseIssueComment()
protected
parseIssueComment(array<string|int, mixed> $payload, string $rawBody) : Message
Parameters
- $payload : array<string|int, mixed>
- $rawBody : string
Return values
MessageparseReviewComment()
protected
parseReviewComment(array<string|int, mixed> $payload, string $rawBody) : Message
Parameters
- $payload : array<string|int, mixed>
- $rawBody : string
Return values
MessagerenderBody()
protected
renderBody(PostableMessage $message) : string
Parameters
- $message : PostableMessage