-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
164 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,6 @@ | |
|
||
备用机通知提醒转发程序,会在收到短信或者未接电话时自动发送提醒内容至指定邮箱。 | ||
|
||
### 快速上手 | ||
|
||
首先需要在【首页- 邮件参数设置】中填入邮箱的相关信息: | ||
|
||
1. SMTP服务器:邮箱的发件服务器地址,如 smtp.qq.com | ||
2. 端口号:SMTP服务器的端口号,注意本程序默认启用了SSL加密,一般SMTP服务器的端口号为 465 | ||
3. 发件人昵称:默认为 Transmis,若收件人和发件人地址相同,收到提醒时可能不会显示自定义的昵称,而显示 “我” | ||
4. 发件人邮箱:用于发送提醒邮件的邮箱,例如 [email protected] | ||
5. 发件人密码/授权码:用于发送提醒邮件的密码,QQ邮箱可在邮箱设置中生成一组三方邮件服务专用的授权码,其他邮箱可能需要输入登录密码 | ||
6. 收件人邮箱:用于接收提醒的邮箱,例如 [email protected] | ||
|
||
然后打开主界面的主开关即可 | ||
|
||
### 权限说明 | ||
|
||
由于显而易见的原因,本程序需要以下权限才能正常工作 | ||
|
@@ -27,7 +14,7 @@ | |
|
||
在某些系统上(如小米、华为等)可能需要手动在启动管理中将本程序设置为【允许被系统唤醒】 | ||
|
||
### 邮件提醒模板 | ||
### 提醒内容设置 | ||
|
||
短信提醒: | ||
|
||
|
@@ -39,14 +26,36 @@ | |
1. 标题:默认为【你的备用机有一个未接电话】,可进行设置,暂不支持通配符 | ||
2. 内容:默认为【电话:%s \n时间:%s \n响铃:%s 秒】,通配符【%s】分别代表电话号码、呼入时间和响铃时间 | ||
|
||
### 提醒方式设置 | ||
|
||
本程序支持「邮件提醒」和「钉钉提醒」两种方式,可同时启用。 | ||
|
||
使用邮件提醒时,首先需要在【首页- 邮件参数设置】中填入邮箱的相关信息: | ||
|
||
1. SMTP服务器:邮箱的发件服务器地址,如 smtp.qq.com | ||
2. 端口号:SMTP服务器的端口号,注意本程序默认启用了SSL加密,一般SMTP服务器的端口号为 465 | ||
3. 发件人昵称:默认为 Transmis,若收件人和发件人地址相同,收到提醒时可能不会显示自定义的昵称,而显示 “我” | ||
4. 发件人邮箱:用于发送提醒邮件的邮箱,例如 [email protected] | ||
5. 发件人密码/授权码:用于发送提醒邮件的密码,QQ邮箱可在邮箱设置中生成一组三方邮件服务专用的授权码,其他邮箱可能需要输入登录密码 | ||
6. 收件人邮箱:用于接收提醒的邮箱,例如 [email protected] | ||
|
||
使用钉钉提醒时,需要执行下列步骤: | ||
|
||
1. 任意拉两个人成立一个群组,然后将其他人踢出群。 | ||
2. 在群设置->群机器人中添加一个新的「自定义机器人」 | ||
3. 复制自定义机器人的链接中的“access_token=”后面的内容 | ||
4. 点击Transmis首页的钉钉机器人设置,输入复制的Token | ||
|
||
然后打开主界面的主开关,以及短信和电话相应提醒开关即可 | ||
|
||
### 其他可选项 | ||
|
||
1. 合并长短信:收到同一发信人的连续多条短信时会自动将内容进行合并,不会多次提醒 | ||
|
||
# License | ||
|
||
Copyright (C) 2017 dss886 | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/src/main/java/com/dss886/transmis/sender/DingDingSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package com.dss886.transmis.sender; | ||
|
||
import android.text.TextUtils; | ||
import android.util.Log; | ||
import android.widget.Toast; | ||
import com.dss886.transmis.base.App; | ||
import com.dss886.transmis.utils.Tags; | ||
import okhttp3.*; | ||
import org.json.JSONObject; | ||
|
||
import java.util.concurrent.Executor; | ||
import java.util.concurrent.Executors; | ||
|
||
/** | ||
* Created by dss886 on 2017/9/22. | ||
*/ | ||
|
||
public class DingDingSender { | ||
|
||
private static final String URL = "https://oapi.dingtalk.com/robot/send?access_token="; | ||
|
||
private MediaType mMediaType = MediaType.parse("application/json; charset=utf-8"); | ||
private OkHttpClient mClient = new OkHttpClient(); | ||
private Executor mExecutor = Executors.newSingleThreadExecutor(); | ||
|
||
public void send(String title, String content) { | ||
if (TextUtils.isEmpty(title) || TextUtils.isEmpty(content)) { | ||
return; | ||
} | ||
mExecutor.execute(() -> { | ||
try { | ||
String url = URL + App.sp.getString(Tags.SP_DING_TOKEN, null); | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(title).append("\n\n"); | ||
for (String line : content.split("\n")) { | ||
sb.append("> ").append(line).append("\n\n"); | ||
} | ||
JSONObject message = new JSONObject(); | ||
message.put("msgtype", "markdown"); | ||
JSONObject markdown = new JSONObject(); | ||
markdown.put("title", title); | ||
markdown.put("text", sb.toString().trim()); | ||
message.put("markdown", markdown); | ||
|
||
RequestBody body = RequestBody.create(mMediaType, message.toString()); | ||
Request request = new Request.Builder().url(url).post(body).build(); | ||
Response response = mClient.newCall(request).execute(); | ||
Log.d("DingDingSender", response.body().string()); | ||
} catch (Exception e) { | ||
Toast.makeText(App.me(), e.getMessage(), Toast.LENGTH_SHORT).show(); | ||
e.printStackTrace(); | ||
} | ||
}); | ||
} | ||
|
||
} |
2 changes: 1 addition & 1 deletion
2
.../com/dss886/transmis/mail/MailSender.java → ...om/dss886/transmis/sender/MailSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.