MIT License

项目介绍

wtfaremyinitials/osa-imessage 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 MIT License 许可证,目前获得 330 个 Star、49 次 Fork。

仓库全名
wtfaremyinitials/osa-imessage
开源许可证
MIT License
Star 数
330
Fork 数
49
未关闭 Issue
8

README 摘要

osa-imessage ==== Send and receive iMessages through nodejs Installation === Requires OSX 10.10 Yosemite Usage ==== Be sure to require osa-imessage: Send a message Receive messages Send message to name Send message to group Get recent chats API === Send a message send(handle, text) -> Promise Sends a message to the specified handle. handle Type: string The user or group to send the message to, in one of the…

完整内容见 GitHub 原始 README 或本页 。

常见问题

osa-imessage 用什么语言开发?

主要使用 JavaScript 编写,采用 MIT License 许可证,目前有 330 个 Star。

osa-imessage 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 osa-imessage 的源码?

可以直接克隆仓库:git clone https://github.com/wtfaremyinitials/osa-imessage.git,默认分支为 master;安装与运行步骤见仓库 README。

osa-imessage 最近还在维护吗?

仓库最近一次更新为 2021年2月22日,当前有 8 个未关闭 Issue;Star 数为 330,可作为社区活跃度的参考。

关于

Send and receive iMessages with nodejs

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
439
价值分
213
活跃状态
活跃

语言占比

JavaScript

README

osa-imessage

styled with prettier

Send and receive iMessages through nodejs

Installation

Requires OSX 10.10 Yosemite

npm install osa-imessage --save

Usage

Be sure to require osa-imessage:

const imessage = require('osa-imessage')

Send a message

imessage.send('+15555555555', 'Hello World!')

Receive messages

imessage.listen().on('message', (msg) => {
    if (!msg.fromMe) console.log(`'${msg.text}' from ${msg.handle}`)
})

Send message to name

imessage.handleForName('Tim Cook').then(handle => {
    imessage.send(handle, 'Hello')
})

Send message to group

imessage.send('chat000000000000000000', 'Hello everyone!')

Get recent chats

imessage.getRecentChats(20) // Defaults to 10

API

Send a message

send(handle, text) -> Promise

Sends a message to the specified handle.

handle

Type: string

The user or group to send the message to, in one of the following forms:

  • phone number (+1555555555)
  • email address ([email protected])
  • group chat id (chat000000000000000000)

text

Type: string

The content of the message to be sent.

return

Type: Promise<>

A promise that resolves when the message is sent, and rejects if the message fails to send.

Receive messages

listen([interval]) -> EventEmitter

Begins polling the local iMessage database for new messages.

interval

Type: number

The rate at which the database is polled for new messages. Defaults to the minimum of 1000 ms.

return

Type: EventEmitter

An event emitter with that listeners can be attached to. Currently it only has the message event.

Example message event

{
    text: 'Hello, world!',
    handle: '+15555555555',
    group: null,
    date: new Date('2017-04-11T02:02:13.000Z'),
    fromMe: false,
    guid: 'F79E08A5-4314-43B2-BB32-563A2BB76177'
}

Example group message event

{
    text: 'Hello, group!',
    handle: '+15555555555',
    group: 'chat000000000000000000',
    date: new Date('2017-04-23T21:18:54.943Z'),
    fromMe: false,
    guid: 'DCFE0EEC-F9DD-48FC-831B-06C75B76ACB9'
}

Get a handle for a given name

handleForName(name) -> Promise<handle>

name

Type: string

The full name of the desired contact, as displayed in Messages.app.

return

Type: Promise<string>

A promise that resolves with the handle of the contact, or rejects if nobody was found.

Get the name associated with a given handle

nameForHandle(handle) -> Promise<name>

handle

Type: string

The handle of a contact.

return

Type: Promise<string>

A promise that resolved with the full name of the desired contact, as displayed in Messages.app.

Get recents chats

getRecentChats(limit) -> Promise

limit

Type: integer

Amount of recent chats to return.

return

Type: Promise

A promise that resolves with an array of chats.

评论

暂无评论