Add modern API send and receive support#5
Conversation
…evoice Fix import error for latest googlevoice
* Replace temporary code with generic code minus api key generation * Make sms sending use the new api for sending texts . This now supports group texts * Implement dynamic hash generation for all requests * Add api_key config option for new google voice api key If api_key is present, will attempt to use new sms endpoint first
* Remove unnecssary json import * Move voice object construction back to try/except as it could throw an exception on construction
* Remove legacy parsing code * Add miscellaneous updates to plugin * Add proper support for rendering new messages * Address new message order and message id issues
| def __init__(self, number, messages): | ||
| self.number = number | ||
| self.messages = messages | ||
| self.__messages = OrderedDict([(msg["msg_id"], msg) for msg in messages]) |
There was a problem hiding this comment.
I left the format of the message item basically as it was in the original code. I'm storing them in an ordered dict so I can take the difference between the left and right hand side conversations during an update. The length of the conversation messages is set by the new API so the old system will always return nothing
|
|
||
| try: | ||
| conversations = reversed(cPickle.loads(conv)) | ||
| conversations = [ |
There was a problem hiding this comment.
Removed the Conversation class copy from the receive module as it was only used in one place and it's easy enough to just initialize it here instead.
| for conversation in conversations: | ||
| if not conversation.conv_id in conversation_map: | ||
| conversation_map[conversation.conv_id] = conversation | ||
| if conversation.number not in conversation_map: |
There was a problem hiding this comment.
I couldn't find a persistent conversation ID in the new response body at all. I think it's acceptable to just use the phone number / group message id as the unique identifier.
Send / Receive SMS with new google voice API
The main inspiration for wrapping around the hidden modern google voice API is that this code allows one to be able to respond to group messages.
-Note: this is now a requirement. See screenshots at bottom for retreiving API key
This plugin now supports responding to group texts: see screenshot below
Not being able to respond to group texts because of limitations of the pygooglevoice package was the inspiration for this update.
TODOS:
Either:
A) remove pygooglevoice dependency as it is only used for login now
B) ideally, make necessary updates to pygoogle voice to wrap around new API
Figure out how to retrieve API key automatically.
Retrieving api key
The simplest way is to go to the developer tools in your browser and to see the requests
being sent. See screenshots below
Chromium 71.0.3578.98 Arch Linux
Mozilla Firefox 64.0.2
@tych0 @rxcomm
This is really just a proof of concept and I'd prefer to refactor this module a bit, but it does the job. You guys did some pretty complicated stuff with weechat that is still over my head so major kudos to you all.