@@ -68,10 +68,25 @@ def post(self):
6868 # [END error]
6969
7070
71+ # [START send-chat-to-user]
72+ class SendChatHandler (webapp2 .RequestHandler ):
73+ def post (self ):
74+ user_address = 'example@gmail.com'
75+ msg = ('Someone has sent you a gift on Example.com. '
76+ 'To view: http://example.com/gifts/' )
77+ status_code = xmpp .send_message (user_address , msg )
78+ chat_message_sent = (status_code == xmpp .NO_ERROR )
79+
80+ if not chat_message_sent :
81+ # Send an email message instead...
82+ # [END send-chat-to-user]
83+ pass
84+ # [START send-chat-to-user]
85+
86+
7187# [START chat]
7288class XMPPHandler (webapp2 .RequestHandler ):
7389 def post (self ):
74- print "REQUEST POST IS %s " % self .request .POST
7590 message = xmpp .Message (self .request .POST )
7691 if message .body [0 :5 ].lower () == 'hello' :
7792 message .reply ("Greetings!" )
@@ -83,4 +98,5 @@ def post(self):
8398 ('/_ah/xmpp/presence/available' , PresenceHandler ),
8499 ('/_ah/xmpp/error/' , ErrorHandler ),
85100 ('/send_presence' , SendPresenceHandler ),
101+ ('/send_chat' , SendChatHandler ),
86102])
0 commit comments