Skip to content

Comments

Add modern API send and receive support#5

Merged
rxcomm merged 10 commits intorxcomm:masterfrom
tobocop2:add_modern_send_and_receive_support
Jul 11, 2019
Merged

Add modern API send and receive support#5
rxcomm merged 10 commits intorxcomm:masterfrom
tobocop2:add_modern_send_and_receive_support

Conversation

@tobocop2
Copy link
Contributor

@tobocop2 tobocop2 commented Jan 28, 2019

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.

  • Send and retrieve sms with the new modern api
  • Add api_key config option for new google voice api key
    -Note: this is now a requirement. See screenshots at bottom for retreiving API key
  • Improved response time for receiving sms
  • Removed beautiful soup dependency

This plugin now supports responding to group texts: see screenshot below

GroupMessage

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

chromium

Mozilla Firefox 64.0.2

firefox

@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.

…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])
Copy link
Contributor Author

@tobocop2 tobocop2 Jan 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants