Updates
Writing this plugin in python has been nothing but a joy. I've honestly never had an easier time just whipping out a script and adding features to it. I almost did it in perl, as weechat has a scripting interface for perl and I am more knowledgeable with perl, but I feel as if I would have had a harder time writing this in perl.
Recent changes to the script include:
- Now sends entire message body as a reply. (IMAP breaks the message body into multiple lines, and this was tripping up my script since I expected it all on one line)
- Does not send the user's signature or quoted messages if user defines strings that indicate a signature:
- User can define what strings are present that indicate a signature so that the entire message history is not sent.
i.e. Gmail on Android sends my signature asTony Lademan
so I add that to the array, but Gmail on the web sends my signature as
-- Tony Lademan
so I also add "--" to the array as well. Similarly, if you don't have a signature, but your client quotes messages with a string such as On DATE, NAME wrote:, then you can add wrote: or the name to your array. Commands are described in the comment body of the script. Multiple strings can be stored and will be used to determine when the script should stop reading the message body.
- Rudimentary help descriptions for the commands.
There's no change log in the file itself yet, not sure if I should do that or push this to its own git repo and make a separate CHANGELOG file that aggregates all of the relevant logs from my current "scripts" repo. Or just push my entire scripts repo somewhere public and not give a shit.
Link to the original post with links to the source.
Here it is
As promised, I'm releasing the code to my recent weechat script in a state that I am mildly comfortable with.
Pretty source
Download (My server tries to execute .py files, so you'll need to rename it)
In my haste, I do not have error checking for things like failed logins. Make sure your username and password are correct if you try to use this.
You will need to have the imaplib python module installed.
Solving problems that never really existed
I use a combination of weechat and bitlbee to have access to my oscar and xmpp chat accounts right next to irc. For a while it was set up to text me from Google Voice whenever I received a message from marked as away. The problem is that Voice does not have a public API. The tool I was using was basically using curl to log in and pull data from the web page. It was very hacky, and when Google changed their authentication recently, it was completely broken.
Jason gave me the idea of using email instead. This was much easier to set up and since it uses a long standing standard, it shouldn't break.
This was good, but to respond to the messages I received, I'd still have to SSH into my computer, which is kind of painful on my phone over 3G and without a real keyboard.
To solve this non-issue (I really don't need to respond to people instantly), I wrote a python script for weechat that logs in to my secondary (or is it my tertiary) gmail account, where the replies are sent, and checks for new messages via imap. The only external library needed is imaplib, to facilitate imap communication. The format is easily abusable: If it is sent from my main gmail, then it assumes it is a reply. The subject contains the recipient of my message, since my notifications put the person in the subject, and the body is the message itself. It's pretty simple to parse the imap message for this information, and even simpler to use the weechat library to send the message to the appropriate person. I don't count the weechat library as external since it is implied when I say this is a weechat script.
The script checks every five minutes and so far works wonderfully.
I guess now that when I'm marked away, I'm not really away, per se.
I need to clean up the code a bit, make it more generic, and take advantage of setting options within weechat (I currently hard code my login information), but I plan to post the code here. I'll probably detail the entire set up I have since it is a combination of two plugins. Because of this requirement of the other script (away_action), I'm not sure if it would be appropriate to submit to the weechat script repository.
Anyway, I was able to whip this out in very little time, and I think I'm finally beginning to understand the appeal of python.
Posted from WordPress for Android
There is a sticky note on the TV
Do not
turn off
Wii under
penalty of
DEATH!
Phil and I got to the third stage of Wily's castle last night, but if you save the game and turn it off you start right back at the first stage of the castle, so we had to leave it on over night. I got bored part way through the night and beat the third stage and got through the fourth, but kept dying on the final boss.. :neutral: I think it was the Oreos and half-gallon of milk that helped me get that far :razz:
I don't know what I'm going to do with myself this break (conscience says: "Get your chem lab done early, get caught up in data networks, look at your systems lab," but who listens to that anyway?). I played around a bit with python last night. Fairly simple stuff so far, just figuring out how loops and functions work in this crazy language. Up next is GUI stuff. The mpd side of things is damn easy, all the mpd commands are extremely straight forward (and are the exact same ones I've already played around with in perl, oddly), so once I get the GUI stuff down it should be pretty easy to implement a basic music controller.
..I think I'm going to fall asleep soon... I slept from about four after my systems exam to roughly ten or so yesterday... My sleep schedule is complete poop right now. It's terrible.