adium命令行包装器
adium-sh的Python项目详细描述
adium shell(adium sh)是adium的命令行工具和python包装器。
说明
adium sh基于adium的AppleScript support提供shell实用程序和python包装器。
功能
当前功能包括:
- 设置默认服务和帐户
- 使用准确的帐户名或别名发送消息
- 使用模式或外部API接收和回复消息(目前支持Simsimi)
- 对事件作出反应
安装
$ pip install adium-sh
用法
必须将要与当前使用关联的帐户和服务指定为命令行参数或在配置文件中。当将它们指定为参数时,必须将它们放在子命令之前。
发送消息
使用帐户名发送消息:
$ adiumsh -s GTalk -t yourname@gmail send -b buddy@gmail.com Hello, there <<EOF
使用别名发送消息:
$ adiumsh -s GTalk -t yourname@gmail.com send -a 'John Smith' Hello, there <<EOF
将默认配置文件设置为~/.adiumsh:
[default] service = GTalk account = yourname@gmail.com
然后,您可以发送消息,而无需指定-s/--service和-t/--account:
$ adiumsh send -a 'John Smith'
您也可以将消息作为参数传递:
$ adiumsh send -a 'John Smith' -m 'Hello, there'
接收消息
必须指定聊天方法才能接收消息。默认情况下,adium sh使用“简单聊天”,基本上是根据您设置的模式回复收到的消息。必须在配置文件中设置模式,可能类似于以下设置:
[default] service = GTalk account = yourname@gmail.com [chat-default] type = wildcard patterns = *hello*: hi *what*: sorry *: I'm not available now
然后,可以使用-c/--chat参数调用“receive”子命令:
$ adiumsh receive -c default
模式是一个字符串对列表,其中每一对用冒号分隔。冒号左边的字符串是与接收到的文本匹配的模式,右边的字符串是相应的回复文本。在chat部分还有一个“type”选项,默认为使用globbing模式匹配的“通配符”;另一个值是使用正则表达式的“regex”。
您还可以使用“simsimi chat”,它会在收到消息后点击simsimi api。您必须在配置文件中设置api密钥和密钥类型(“trial”(默认值,或“paid”):
[chat-simi] simi-key = some-really-long-key simi-key-type = trial
然后,从命令行调用“receive”并进行此聊天:
$ adiumsh receive -c simi
在默认设置中设置默认聊天:
[default] service = GTalk account = yourname@gmail.com chat = default [chat-default] patterns = *hello*: hi *what*: sorry *: I'm not available now [chat-another] patterns = *: not here
现在,您还可以从命令行切换聊天,而不是默认值:
$ adiumsh receive -c another
待办事项
- 完整的python包装器api以支持applescript
- 基于包装器的详尽命令