Solution for sending Whatsapp via sqlite "INSERT INTO"

2,469 views
Skip to first unread message

Amos Wong

unread,
Sep 29, 2013, 11:17:01 AM9/29/13
to tas...@googlegroups.com
Yo everyone!

I found this from Pockable : http://www.pocketables.com/forum/showthread.php?t=11947 which lead me to a Spanish forum : http://www.htcmania.com/showthread.php?p=8993462 

Origin : pepelolo38 

Since part of the commands are in Spanish, I thought of recreating them my Tasker [English] and share it here. A3 ~ A9 below are copied and modified from the original source.

For this task, I use
  1. SQLite Installer
  2. Rooted Galaxy Nexus - Android 4.1
  3. Whatsapp v2.11.23

Send Whatsapp (491)

Run Both Together
A1: Variable Set [ Name:%nummsg To:%arcomm Do Maths:Off Append:Off ] 

A2: Variable Split [ Name:%nummsg Splitter:[}{] Delete Base:Off ] 

A3: Variable Set [ Name:%wa_number To:%nummsg1 Do Maths:Off Append:Off ] 

A4: Variable Set [ Name:%wa_key_id To:%TIMES Do Maths:Off Append:Off ] 

A5: Variable Set [ Name:%wa_message To:%nummsg2 Do Maths:Off Append:Off ] 

A6: Variable Set [ Name:%wa_timestamp To:%TIMEMS Do Maths:Off Append:Off ] 

A7: Variable Set [ Name:%wa_received_timestamp To:%TIMEMS Do Maths:Off Append:Off ] 

A8: Run Shell 
[ Command:sqlite3 /data/data/com.whatsapp/databases/msgstore.db "INSERT INTO messages (key_remote_jid, key_from_me, key_id,status, needs_push, data, timestamp, media_url, media_mime_type, media_wa_type, media_size, media_name, latitude, longitude, thumb_image, remote_resource, received_timestamp, send_timestamp, receipt_server_timestamp, receipt_device_timestamp, raw_data, media_hash, recipient_count, media_duration, origin) VALUES ('%wa_n...@s.whatsapp.net',1, '%wa_key_id-1' ,0,0,'%wa_message',%wa_timestamp,'','','0',0,'',0.0,0.0,'', '',%wa_received_timestamp,-1,-1,-1,0,'',0,0,0);" Timeout (Seconds):0 Use Root:On Store Output In: Store Errors In: Store Result In: ] 

A9: Kill App [ App:WhatsApp Use Root:On ] 

Description

A1 ~ A2 : For processing message received from Autoremote by joaomgcd [Ignore if you don't use it]
A3 ~ A7 : Setting up necessary variables
A8         : The command to insert data into msgstore.db
A9         : On my phone, this action is required for Whatsapp to send the message. However, it doesn't seem to exit Whatsapp (My whatsapp will just to blank and come back again).

Note:

On my phone
  • It takes 30~40 seconds to send a message when my screen is off.
  • 10~12 seconds when Whatsapp is opened.
  • The message is not shown in Whatsapp's homepage. (It is shown in the conversation)
  • The entire task takes 1~2 seconds to run.
Message has been deleted

Will Vande

unread,
Sep 29, 2013, 10:00:26 PM9/29/13
to tas...@googlegroups.com
That is really cool. Great job.

Martin Hennessy

unread,
Oct 2, 2013, 6:39:18 AM10/2/13
to tas...@googlegroups.com
I use something similar but thought I'd mention this 'bug' that can happen:

when you INSERT '%wa_message' into 'data', bear in mind your typed message will replace %wa_message.

if that typed message contains an apostrophe, your message won't send.

why?

the apostrophe effectively closes 'data' insert and the rest of the text isn't understood by sqlite.

examples:

'i'm not going to work' - won't work because only 'i' will be inserted into data, sqlite won't know what to do with m not going to work'
'im not going to work' - on the other hand WILL work!

'this will work, won't it' - won't work because of the apostrophe, the text t it' will be left over and cause an error
'this will work, wont it' - will work

so be careful with apostrophes and sqlite whatsapp messages!

(this "bug" took me AGES to work out!)

mlesir

unread,
Oct 2, 2013, 12:52:47 PM10/2/13
to tas...@googlegroups.com
In Spanish we had the same trouble with our á, é, etc...
We use the action for (á,é,í...) , and search Replace (a,e,i) to convert this:

"María va en camión"

To this:

"Maria va en camion"

QUITAR ACENTOS MENSAJE (1006)
A1: For [ Variable:%for Ítems:á,é,í,ó,ú,Á,É,Í,Ó,Ú ]
A2: Add to variable [ Nombre:%con Valor:1 Módulo (wrap around):0 ]
A3: Set variable [ Nombre:%Con A:%Voc(%con) Calcular:Apagado Añadir:Apagado ]
A4: Variable Search Replace [ Variable:%par1 Buscar:%for Ignore Case:Apagado Multi-Line:Apagado One Match Only:Apagado Almacenar Coincidencias En: Reemplazar Coincidencias:Encendido (enabled) Reemplazar Con(replace with) :%Con ]
A5: End For
A6: Devolver [ Valor:%par1 Parar:Encendido ]

Every message (%par1) pass in this task. Previously we have an array (%Con) with the vocals in the same order that in the for but without the '.

And for search the contacts we use replace the vocal with "_" so "María" converts in "Mar_a".

Julio García Muñoz

unread,
Dec 4, 2013, 5:56:35 PM12/4/13
to tas...@googlegroups.com
Just in case somebody stumbles upon this old thread...I made a free plugin to automate intercepting WhatsApp notifications and sending messages (without the character limitation). Feel free to give it a try:

Ahmed Saleh

unread,
Mar 23, 2014, 10:40:16 AM3/23/14
to tas...@googlegroups.com
Hello Mr. Julio García Muñoz
Can you help me out in this topic ? (my 3rd Comment)

I am trying to send a message to multiple contacts but it just sends to the first index of the array (check the above link for more details about the implementation )
Reply all
Reply to author
Forward
0 new messages