This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
todo_jabber_server / todo_jabber_server.groovy
| c44b3ff7 » | igouss | 2008-08-26 | 1 | #!/usr/bin/env groovy -cp lib/smack.jar:lib/smackx.jar | |
| 2 | |||||
| 3 | import java.io.* | ||||
| 4 | import org.jivesoftware.smack.* | ||||
| 5 | import org.jivesoftware.smack.packet.* | ||||
| 6 | import org.jivesoftware.smack.filter.* | ||||
| 7 | |||||
| 8 | def connection = new XMPPConnection("jabber.org") | ||||
| 9 | connection.connect() | ||||
| 10 | connection.login("todobot123", "passwd") | ||||
| 11 | |||||
| 12 | presence = new Presence(Presence.Type.available) | ||||
| 13 | presence.setStatus("Getting Things Done!") | ||||
| 14 | connection.sendPacket(presence) | ||||
| 15 | |||||
| 16 | filter = new AndFilter(); | ||||
| 17 | filter.addFilter(new FromMatchesFilter("i.gouss@gmail.com")); | ||||
| 18 | filter.addFilter(new PacketTypeFilter(Message.class)); | ||||
| 19 | |||||
| 20 | |||||
| 21 | class TodoPacketListener implements PacketListener { | ||||
| 22 | private XMPPConnection connection | ||||
| 23 | |||||
| 24 | TodoPacketListener(XMPPConnection connection) { | ||||
| 25 | this.connection = connection | ||||
| 26 | } | ||||
| 27 | |||||
| 28 | void processPacket(Packet packet) { | ||||
| 29 | try { | ||||
| 30 | def message = (Message) packet | ||||
| 31 | def program = ["/Users/i_gouss/bin/todo.py", "-p"] | ||||
| 32 | def args = message.getBody().split().toList(); | ||||
| 33 | program.addAll(args) | ||||
| 34 | |||||
| 35 | def proc = program.execute() | ||||
| 36 | proc.waitFor() | ||||
| 37 | |||||
| 38 | def reply = new Message(message.getFrom(), Message.Type.chat) | ||||
| 39 | reply.setFrom(message.getTo()) | ||||
| 40 | reply.setThread(message.getThread()) | ||||
| 41 | reply.setBody(proc.in.text) | ||||
| 42 | |||||
| 43 | connection.sendPacket(reply) | ||||
| 44 | } catch(Exception ex) { | ||||
| 45 | println ex | ||||
| 46 | } | ||||
| 47 | } | ||||
| 48 | } | ||||
| 49 | |||||
| 50 | connection.addPacketListener(new TodoPacketListener(connection), filter) | ||||
| 51 | |||||
| 52 | InputStreamReader converter = new InputStreamReader(System.in) | ||||
| 53 | BufferedReader input = new BufferedReader(converter) | ||||
| 54 | input.readLine() | ||||







