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 ...
随机推荐
- 【小程序开发总结】微信小程序开发常用技术方法总结
1.获取input的值 <input bindinput="bindKeyInput" placeholder="输入同步到view中"/> b ...
- luogu P3393 逃离僵尸岛
luoguP3393逃离_僵尸岛_ 一道洛谷不知道哪门子月赛的题 可以用此题来练习最短路算法 SPFA和dijkstra的练习题(关于Floyed,他死了 思路: 本题是最短路板子. 首先就是建立虚点 ...
- dede导航栏目调用
1.基础调用 {dede:channel row='5' type ='top' } <li><a href="[field:typelink/]">[fi ...
- InnoDB 锁
参看文章: innodb的意向锁有什么作用? 2.<MySQL技术内幕:InnoDB存储引擎> InnoDB存储引擎中的锁 InnoDB中的锁介绍 InnoDB存储引擎既支持行级锁,也支持 ...
- LeetCode699. Falling Squares
On an infinite number line (x-axis), we drop given squares in the order they are given. The i-th squ ...
- Java学习(正则表达式、Date类、DateFormat类、Calendar类)
一.正则表达式 1.概念:英语:Regular Expression,在代码中常简写为regex.正则表达式,是一个字符串,使用单个字符串来描述.用来定义匹配规则,匹配一系列符合某个句法规则的字符串. ...
- RabbitMQ系列之RabbitMQ集群
本文的集群是RabbitMq 自身的Cluster搭建 . #hosts准备: vim /etc/hosts #172.16.3.79 s1 #172.16.3.105 s2 172.16.2.10 ...
- JSON解析代码
/** * 解析有数据头的纯数组 */ private void parseHaveHeaderJArray() { //拿到本地JSON 并转成String String strByJson = J ...
- 【POJ】1704.Georgia and Bob
题解 感觉挺神奇的 我们把石子从后往前相邻的两个两两配对,这样他们之间的空格就相当于一堆石子 而配对后左边棋子移动,右边棋子也一定可以跟上取 转化成简单的nim游戏,最后只要看转化出的这(N - 1) ...
- 14个你可能不知道的JavaScript调试技巧
调试JS的时候,搜索一下这个标题