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 ...
随机推荐
- 如何成为技术大牛——阿里CodeLife
天天写业务代码的程序员,怎么成为技术大牛,开始写技术代码? 几个误区 跟着大牛,就可以成为大牛.首先,大牛时间很宝贵,不可能花很多时间去指导你:其次,简单的模仿大牛,只能学到表面知识,不可能成为大牛: ...
- 在虚拟机(vmware)上安装CentOS
第一步是安装虚拟机,这个比较简单就不讲了. 第二步准备CentOS的镜像文件准备安装 第三步安装CentOS: 新建虚拟机 选择自定义配置 选择硬件兼容标准 选择是否让vmware安装操作系统 选择将 ...
- java基础45 IO流技术(输入字符流/缓冲输入字符流)
一.输入字符流 1.1.输入字符流体系 ------| Reader:输入字符流的基类(抽象类) ----------| FileReader:向指定文件读取数据的输入字符流(把硬盘上的数据读取到程 ...
- Java线程:新特征-有返回值的线程《转》
原始文章 在Java5之前,线程是没有返回值的,常常为了“有”返回值,破费周折,而且代码很不好写.或者干脆绕过这道坎,走别的路了. 现在Java终于有可返回值的任务(也可以叫做线程)了. ...
- git —— Feature分支
添加新功能时,新建feature分支 分支上开发完成后,再进行合并.最后删除feature分支 $ git checkout -b feature-vulcan 开发完毕后,切换回添加的分支,进行合并 ...
- caffe细节
1.BN层参数设置 在训练时所有BN层要设置use_global_stats: false(也可以不写,caffe默认是false) 在测试时所有BN层要设置use_global_stats: tru ...
- ROS二进制日志包 ROS binary logger package
原文网址: 1 http://www.ros.org/news/2017/02/ros-binary-logger-package.html 2 https://github.com/CNR-ITIA ...
- 微信小程序蓝牙模块
蓝牙部分知识 关于Service: 每个设备包含有多个Service,每个Service对应一个uuid 关于Characteristic 每个Service包含多个Characteristic,每个 ...
- CVE-2013-3893
前方高能!!!这篇博文比较长,因为我把完整的调试过程都记录下来了,感兴趣的童鞋可以看下.没有耐心的童鞋可以直接跳到最后看总结:) Microsoft Internet Explorer 远程代码执行漏 ...
- 大数据统计分析平台之三、Kibana安装和使用
kibana安装 1.到官网下载kibana: cd /usr/local/software wget https://artifacts.elastic.co/downloads/kibana/ki ...