How to read out WhatsApp messages with Tasker and react on their content in real time
http://technologyworkroom.blogspot.sg/2013/05/tasker-how-to-read-out-whatsapp.html
Tasker can read out incoming or stored WhatsApp Messages, I used Tasker to do the following things on WhatsApp:
- Display the incoming messages in iOS style, no need to pull down the notification menu to read the messages. The whole message is displayed in the menu bar. See screenshot for details
- Play different notification sounds for different contacts or different message content, this way you can for example get a special notification if your name is mentioned.
- Mute WhatsApp at specific times or at specific locations, without muting other notifications.
- Update: Read aloud WhatsApp messages
What we need:
- Tasker
- root. I want you to root your phone now! You need root for SQLite, we need it to read out the database of WhatsApp.
- SQLite for Android
- Kyo-Tux Aeon HD icon pack, provides useful icons for Tasker, its free and lightweight, so grab it
Here is the complete profile:
Profile: WhatsApp Statusbar
Priority: 9 CoolDown: 0
Event: Notification [ Owner Application:WhatsApp Title:* ] Enter: WhatsApp Notification
Run Both Together
A1: Run Shell [ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "SELECT timestamp,data,key_remote_jid FROM messages WHERE key_from_me='0' ORDER BY timestamp DESC LIMIT 1;" Timeout (Seconds):15 Use Root:On Store Result In:%sql_result Continue Task After Error:On ]
A2: If [ %sql_result !~ %SQL_RESULT_OLD ]
A3: Variable Set [ Name:%SQL_RESULT_OLD To:%sql_result Do Maths:Off Append:Off ]
A4: Variable Split [ Name:%sql_result Splitter:| Delete Base:On ]
A5: Variable Set [ Name:%sql_result1 To:%sql_result1/1000 Do Maths:On Append:Off ]
A6: Variable Convert [ Name:%sql_result1 Function:Seconds to Date Time Store Result In: ]
A7: Variable Split [ Name:%sql_result1 Splitter: Delete Base:Off ]
A8: Variable Search Replace [ Variable:%sql_result12 Search:\. Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With:: ]
A9: Perform Task [ Name:Number->Name WhatsApp Stop:Off Priority:6 Parameter 1 (%par1):%sql_result3 Parameter 2 (%par2): Return Value Variable:%sql_result3 ]
A10: Wait Until [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %sql_result3 !~R @s.whatsapp.net ]
A11: Array Push [ Name:%WHATSAPP_NOTIFY Position:1 Value:%sql_result3: %sql_result2 Fill Spaces:Off ]
A12: Notify Cancel [ Title:%WHATSAPP_NOTIFY4 Warn Not Exist:Off ]
A13: Variable Clear [ Name:%WHATSAPP_NOTIFY4 Pattern Matching:Off ]
A14: Notify [ Title:%sql_result3: %sql_result2 Text:%sql_result2 Icon:ipack:kyotuxaeonhd:buddy_green Number:0 Permanent:Off Priority:3 ]
A15: Perform Task [ Name:Play Sound Stop:Off Priority:6 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ]
A16: End If
The most important line is A1. Here we use the installed sqlite to save the time, the sender and the content of the last message stored in the WhatsApp database into a Tasker variable. The values are separated by a "|", the time is in ms and the sender is stored as a phone numer. So there are some conversions needed afterwards.
You may have noticed that there is a call to another task at line A9. WhatsApp saves only the number of the contact who send you the message in its database, so we need to convert the number to a real contact name as saved in your phone book. The task "Number->Name WhatsApp" does it. It searches the address book for contacts associated with a WhatsApp account and returns their name. So after line A10 you should know who texted you by name, you can put in if clauses to react different to different names. Here the description of the "Number->Name WhatsApp" task:
Number->Name WhatsApp
A1: Run Shell [ Command:sqlite3 /data/data/com.android.providers.contacts/databases/contacts2.db "SELECT display_name FROM raw_contacts WHERE sync1 like '%par1';" Timeout (Seconds):5 Use Root:On Store Result In:%sql_result_name Continue Task After Error:On ]
A2: If [ %sql_result_name !~R sql_result_name ]
A3: Return [ Value:%sql_result_name Stop:On ]
A4: Else
A5: Return [ Value:%par1 Stop:On ]
A6: End If
At line A15 of the task "WhatsApp Notification" task I call a Tasker task called "Play Sound". That's because I disabled notification sounds in WhatsApp to handle them myself (They are time and WhatsApp message content depandant). Here an example of how a simple "Play Sound" task could look like:
Play Sound
Run Both Together
A1: If [ %par1 ~R .*[Rr]+[Uu]+[Aa]+[Rr]+.* ]
A2: Variable Set [ Name:%tmp To:%VOLS Do Maths:Off Append:Off ]
A3: Wait [ MS:50 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A4: System Volume [ Level:7 Display:Off Sound:Off ]
A5: If [ %SILENT ~ off ]
A6: Play Ringtone [ Type:Notification Sound:Dinosaur Roar Stream:1 ]
A7: Else If [ %HEADSET ~ 1 ]
A8: Play Ringtone [ Type:Notification Sound:Dinosaur Roar Stream:1 ]
A9: End If
A10: Vibrate [ Time:1000 ]
A11: Vibrate [ Time:1000 ]
A12: Vibrate [ Time:1000 ]
A13: Vibrate [ Time:1000 ]
A14: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ]
A15: System Volume [ Level:%tmp Display:Off Sound:Off ]
A16: Else If [ %par1 ~R [Mm][Ii][Aa][Uu]+\b ]
A17: If [ %SILENT ~ off ]
A18: Play Ringtone [ Type:Notification Sound:Miau Stream:1 ]
A19: Else If [ %HEADSET ~ 1 ]
A20: Play Ringtone [ Type:Notification Sound:Miau Stream:1 ]
A21: End If
A22: Else
A23: If [ %par2 !~ 1 ]
A24: If [ %HEADSET !~ 1 ]
A25: If [ %SILENT ~ off ]
A26: Vibrate [ Time:100 ]
A27: Play Ringtone [ Type:Notification Sound:Good news Stream:5 ]
A28: End If
A29: End If
A30: End If
A31: End If
If headphones are connected or phone is on silent mode no sound is played at all. If the message contains something like "Rrruaaarrrr" a dinosaur roar is played at full volume (even with headphones connected) and the phone vibrates for 4 seconds. If a "Miauuu" is in the message a cats miau is played... I'm sure you can do better :)
You can even make Tasker react on a click on one of the notifications, just add the following profile:
Profile: WhatsApp Notification1 Click
Event: Notification Click [ Owner Application:Tasker Title:%WHATSAPP_NOTIFY1 ]
Enter: Open WhatsApp
A1: Load App [ App:WhatsApp Data: Exclude From Recent Apps:Off ]
Duplicate this profile two times so you can click on any of our three custom notifications.
Profile: WhatsApp Notification2 Click
Event: Notification Click [ Owner Application:Tasker Title:%WHATSAPP_NOTIFY2 ]
Enter: Open WhatsApp
A1: Load App [ App:WhatsApp Data: Exclude From Recent Apps:Off ] Profile: WhatsApp Notification3 Click
Event: Notification Click [ Owner Application:Tasker Title:%WHATSAPP_NOTIFY3 ]
Enter: Open WhatsApp
A1: Load App [ App:WhatsApp Data: Exclude From Recent Apps:Off ]
I added another profile which deletes all our custom made WhatsApp notifications automatically after opening WhatsApp. Looks like this:
Profile: WhatsApp opened
Application: WhatsApp Enter: WhatsApp Notification clear
A1: Notify Cancel [ Title:%WHATSAPP_NOTIFY1 Warn Not Exist:Off ]
A2: Notify Cancel [ Title:%WHATSAPP_NOTIFY2 Warn Not Exist:Off ]
A3: Notify Cancel [ Title:%WHATSAPP_NOTIFY3 Warn Not Exist:Off ]
A4: Variable Clear [ Name:%WHATSAPP_NOTIFY* Pattern Matching:On ]
A5: Stop [ With Error:Off Task:WhatsApp Notification ]
Have fun and use this knowledge wisely. Please leave your thoughts in the comments, I'm very excited about your implementations. Hope you read this Ruy Aguilar ;)
cv
How to read out WhatsApp messages with Tasker and react on their content in real time的更多相关文章
- Send a WhatsApp Message programatically -- Tasker WhatsTasker
Here is My code snippet: Uri mUri = Uri.parse("smsto:+9876543210"); Intent mIntent = new I ...
- Solution for sending Whatsapp via sqlite "INSERT INTO"
I use something similar but thought I'd mention this 'bug' that can happen:when you INSERT '%wa_mess ...
- Ultimate Guide to WhatsApp for Business 2019
By Iaroslav Kudritskiy (Source: https://rocketbots.io/blog/the-ultimate-guide-to-whatsapp-business-a ...
- 免费好用的 Apple 工具(Windows 适用)
首先,下载链接: https://pan.baidu.com/s/1Sfx3SB8Ya1aMS01aXk--rA 密码: 6y69 1. Airplay (itools) : ios 可以投屏到win ...
- 所有selenium相关的库
通过爬虫 获取 官方文档库 如果想获取 相应的库 修改对应配置即可 代码如下 from urllib.parse import urljoin import requests from lxml im ...
- Asp.Net MVC+BootStrap+EF6.0实现简单的用户角色权限管理5
我们先直接拷贝下blank.html这个页面的代码,顺带先建立一个Home控制器,并添加Index视图.将代码拷贝进去. <!DOCTYPE html> <html lang=&qu ...
- Android之数据库的创建
一.SQLite介绍 SQLite 一个非常流行的嵌入式数据库,它支持 SQL 语言,并且只利用很少的内存就有很好的性能.此外它还是开源的,任何人都可以使用它.许多开源项目((Mozilla, PHP ...
- Asp.Net MVC中使用ACE模板之Jqgrid
第一次看到ACE模板,有种感动,有种相见恨晚的感觉,于是迅速来研究.它本身是基于bootstrap和jqueryui,但更nice,整合之后为后台开发节省了大量时间. 发现虽然不是完美,整体效果还是不 ...
- IMS Global Learning Tools Interoperability™ Implementation Guide
Final Version 1.1 Date Issued: 13 March 2012 Latest version: http://www.imsglobal ...
随机推荐
- python基础--os模块和sys模块
os模块提供对操作系统进行调用的接口 # -*- coding:utf-8 -*-__author__ = 'shisanjun' import os print(os.getcwd())#获取当前工 ...
- IOS使用SourceTree
一.安装sourceTree 1.下载 访问SourceTree 软件官方下载地址 : https://www.sourcetreeapp.com 下载macos版本 2.安装 安装和windows安 ...
- mvn简单命令
导出maven项目依赖的jar包 mvn dependency:copy-dependencies -DoutputDirectory=lib 编译Java代码 mvn compile eclipse ...
- Java HashCode详解
一.为什么要有Hash算法 Java中的集合有两类,一类是List,一类是Set.List内的元素是有序的,元素可以重复.Set元素无序,但元素不可重复.要想保证元素不重复,两个元素是否重复应该依据什 ...
- xcode7 创建pch文件
1.打开xcode 7.2 项目,在屏幕顶端的工具栏,选择File>New>File..>iOS>Other>PCH File,点击"next"下一步 ...
- OBJECT_ID()的使用方法
数据库中每个对像都有一个唯一的ID值,用Object_name(id)可以根据ID值得到对像的名称,object_id(name)可以根据对像名称得到对象的ID object_id()只能返回用户创建 ...
- MySQL学习笔记:字符串前后补全0
遇到一个需求:不足6位的需要自动补全6位,使用函数LPAD()和RPAD()补全. LPAD(str, len, padstr) 用字符串padstr对str进行左边填充补全直至它的长度达到len个字 ...
- celery在Django中的集成使用
继上回安装和使用Redis之后,看看如何在Django中使用Celery.Celery是Python开发分布式任务列队的处理库.可以异步分布式地异步处理任务,也可定时执行任务等等.通常我们可以在Dja ...
- 2016-2017-2 20155309南皓芯《java程序设计》第十周学习总结
教材内容总结 网络编程 定义:网络编程就是在两个或两个以上的设备之间传输数据. 计算机网络概述: 网络编程的实质就是两个(或多个)设备(例如计算机)之间的数据传输. 网络中的每个设备都会有一个唯一的数 ...
- ubuntu 休眠后窗口边缘出现花边的解决方案
可以确定是nvidia显卡的问题,详细的解决方案请参见:这里 临时的解决方案: compize --replace 永久性的解决方案: sudo add-apt-repository ppa:grap ...