Commit Graph

63 Commits

Author SHA1 Message Date
Anna Schumaker 01a61db2f8 Unescape html escape sequences
Python has a handy module for this, so let's use it to fix escape codes
in messages.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-12-06 13:48:35 -05:00
Anna Schumaker 3ae8ce02b5 Don't open up IMs just to check their info
Instead, we can use the undocumented "im.info" call to find the same
thing.  Additionally, we can use the "is_open" value as the result of
the is_member() thread function.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 16:48:59 -05:00
Anna Schumaker a0644d225c Only check for reply markers at the beginning of each line
Otherwise we could cut the user's message if they use the ">" symbol in
their text.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 15:48:03 -05:00
Anna Schumaker 5cb66f7a7f Email spacing cleanups
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 10:37:47 -05:00
Anna Schumaker 1e767dbfe9 Implement a single fetch_info() function
This already existed, so I just had to define the api calls to use.
Unfortunately, groups return a similar group object so I also have to
define what return object needs to be looked up.  Additionally, IMs have
an extra "return_im" object that needs to be passed to get the full
channel info.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 10:18:16 -05:00
Anna Schumaker 53d9aa4e3d Implement a single mark_messages() function
Rather than having each thread type define its own mark method, let's
instead have them tell us what api call to use to avoid duplicating
work.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 09:18:29 -05:00
Anna Schumaker f517f8c391 Implement a single fetch_messages() function
Rather than having each thread type define its own fetch history method,
let's instead have them tell us what api call to use to avoid
duplicating work

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 08:47:03 -05:00
Anna Schumaker a88669d5e4 Preserve the last seen timestamp
So that we can mark posts from bots as read.  Otherwise we could end up
sending empty messages until another human posts.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-22 08:35:13 -05:00
Anna Schumaker 49d5be8a76 Decode base64 encoded messages before posting
This is needed to unscramble the encoded string, otherwise we won't be
able to find the thread id or message.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-18 09:54:36 -05:00
Anna Schumaker 3a8b556dcc Add license
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-17 11:03:33 -05:00
Anna Schumaker 65e9b15414 Better handling for multipart message replies
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-17 10:55:48 -05:00
Anna Schumaker 867b1edb24 Improve slackpost script
I also enable posting to IMs and return any error that we receive when
attempting to post.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-17 10:29:39 -05:00
Anna Schumaker 265522cb17 Set "oldest" timestamp when reading IMs
Otherwise we will send all messages in the thread

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 16:16:41 -05:00
Anna Schumaker 1d6764564d Properly format IM urls
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 16:06:54 -05:00
Anna Schumaker 3027ec5ba7 Add support for fetching direct messages
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 15:52:42 -05:00
Anna Schumaker 18aa2a5375 Split posts on newline
Slack lets you write posts with multiple paragraphs.  We were joining
everything together, but I think preserving the original newlines will
make things more readable.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 14:54:37 -05:00
Anna Schumaker 5d4cab62e5 Display links as footnotes
Rather than including them in the text that gets wrapped.  This prevents
links from getting split, potentially breaking them.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 14:18:18 -05:00
Anna Schumaker c8c40f1682 Parse channel tags to make them easier to read
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
2016-11-16 10:35:23 -05:00
Anna Schumaker 2779e13692 Add channel url to slack email
This gives us a link directly to the channel to read messages there.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-11-16 09:39:46 -05:00
Anna Schumaker adbfd6d2d6 Filter out empty messages
It's not enough to check for None, we also need to check that there is
actually text in the message.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-11-16 09:14:31 -05:00
Anna Schumaker 3c264554d8 Message handling fixes
Don't create a message object for posts without text.  Additionally, use
the accepted character replacements for unicode characters.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-09-04 14:19:13 -04:00
Anna Schumaker 673bac86bc slackpost: Decode reply as quoted-printable text
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-16 11:42:16 -04:00
Anna Schumaker 14e44c1734 Post to thread object, not channel object.
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-16 11:22:52 -04:00
Anna Schumaker c5e15161bd slackpost: Updates for current email formatting
- Look for thread= lines
- Support posting to both channels and private groups

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-16 11:06:03 -04:00
Anna Schumaker 19496e737c slackmail: Support emailing channels and private groups
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-09 10:38:02 -04:00
Anna Schumaker ca89d98e3a Add support for reading messages through the Thread class
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-09 10:22:58 -04:00
Anna Schumaker 6859f8c3ec Add Group class
And pull more things out of the Channel class and into the Thread class.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-09 09:57:25 -04:00
Anna Schumaker fcd2789c29 Create a new Thread class
I want to create a generic class to represent (public) channels and
(private) groups.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-09 09:34:33 -04:00
Anna Schumaker c10fff756c Replace <@UID> strings with the target user's username
This makes it easier to know who is being spoken to.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-08 19:03:49 -04:00
Anna Schumaker 8d38fffaf4 Fixes for merging messages
I noticed that a merged message reversed all the lines.  This is due to
how slack returns messages in the history() call, so let's parse replies
in two steps to keep everything chronological.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-06-08 16:55:21 -04:00
Anna Schumaker e80b200a31 slackmail: Remove newline at beginning of message
It's not really needed for anything, and may make parsing more
difficult.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-29 08:46:29 -04:00
Anna Schumaker 1bc6d1064f Put channel id on same line as "Reply above this line"
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 14:05:43 -04:00
Anna Schumaker 65e5403165 Merge consecutive messages with the same author
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 13:51:23 -04:00
Anna Schumaker 7b78e9d785 Move Message class into the chat namespace
It makes more sense to put it here, since it's related to chatting.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 13:24:36 -04:00
Anna Schumaker dcd8650e1a Message display improvements
- Put time and poster information on one line
- Wrap message text to 70 characters

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 13:21:38 -04:00
Anna Schumaker 193107574f Simplify hour:minute:second display
Now it's a bit easier to read!

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 12:31:29 -04:00
Anna Schumaker d905ebd375 Remove X-Slack-Channel from email headers
Turns out, gmail doesn't preserve this when replying to messages.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-28 12:25:30 -04:00
Anna Schumaker 5fe26ca0e5 Send email with X-Slack-Header to specify channel
This is slightly more accurate than using channel names to lookup where
to post.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 16:37:37 -04:00
Anna Schumaker d43f0e52d8 Update reply handler
What we really want to do is look for the first line beginning with ">"
and discard everything after it (and the line immediately before it,
just to be safe)

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 16:18:50 -04:00
Anna Schumaker 29815fc28b slackpost: Properly strip out reply markers
Remove all lines beginning with ">", and the line immediately before
them.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 11:11:35 -04:00
Anna Schumaker d07bf33f44 Use the python url parser for encoding arguments
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 10:36:23 -04:00
Anna Schumaker e0d1c85259 Prefer real names for users
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 09:15:22 -04:00
Anna Schumaker b30600b066 Email should show up as the team name
And not as "SlackMail"

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 09:13:00 -04:00
Anna Schumaker ea0eeeb46c Send email to the authenticated user's email address
This is better than hardcoding in my address.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-27 09:12:05 -04:00
Anna Schumaker bbe14fa88d slack: change directory before running
To help find the tokens file, mostly

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 21:32:00 -04:00
Anna Schumaker 6110e5ff3b slackpost.py: Write a script for posting to slack
The idea is that postfix will pipe an email message into this script,
which will then post the reply to slack.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 21:21:46 -04:00
Anna Schumaker d9a6858be8 Mark channels read when updated
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 21:21:45 -04:00
Anna Schumaker 253e0374f0 Mark channels read when updated
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 17:04:56 -04:00
Anna Schumaker b5d715096e Prepare text as an email message
Right now it's hardcoded to send to me.  This should be made
configurable eventually ...

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 16:52:55 -04:00
Anna Schumaker 80706b18c9 Make a list of strings to hold the text
This will be the body of the email message.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2015-05-26 16:42:40 -04:00