def post(self): msg = xmpp.Message(self.request.POST) if 'help' in msg.body: msg.reply( '\r\n<姓名> <年齡> <計算流年(民國年)> 或是參閱說明文件:http://bit.ly/9KaYWJ') elif 'htsay' in msg.body: try: st = msg.body.split(' ') msg.reply(htls.htexp(st[1].encode('utf-8'))) except: msg.reply('輸入錯誤!請參考說明文件:http://bit.ly/9KaYWJ ') elif 'ht' in msg.body: hts = htls.htls().hts re = '' for i in hts: re += i + '→' msg.reply(re) elif 'ls' in msg.body: lss = htls.htls().lss re = '' for i in lss: re += i + '→' msg.reply(re) else: try: st = msg.body.split(' ') re = htls.htls(st[0].encode('utf-8')).all(st[1], st[2]) msg.reply('\r\n' + re) logging.info('HTLS: %s' % re) except: msg.reply('輸入錯誤!請參考說明文件:http://bit.ly/9KaYWJ') #msg.reply(msg.body) logging.info(self.request.POST) logging.info('Msg status: %s' % msg.body)
def post(self): msg = xmpp.Message(self.request.POST) if 'help' in msg.body: msg.reply('\r\n<姓名> <年齡> <計算流年(民國年)> 或是參閱說明文件:http://bit.ly/9KaYWJ') elif 'htsay' in msg.body: try: st = msg.body.split(' ') msg.reply(htls.htexp(st[1].encode('utf-8'))) except: msg.reply('輸入錯誤!請參考說明文件:http://bit.ly/9KaYWJ ') elif 'ht' in msg.body: hts = htls.htls().hts re = '' for i in hts: re += i + '→' msg.reply(re) elif 'ls' in msg.body: lss = htls.htls().lss re = '' for i in lss: re += i + '→' msg.reply(re) else: try: st = msg.body.split(' ') re = htls.htls(st[0].encode('utf-8')).all(st[1],st[2]) msg.reply('\r\n' + re) logging.info('HTLS: %s' % re) except: msg.reply('輸入錯誤!請參考說明文件:http://bit.ly/9KaYWJ') #msg.reply(msg.body) logging.info(self.request.POST) logging.info('Msg status: %s' % msg.body)
# The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. import htls from datetime import datetime while True: print '結束請按 Ctrl + c\n' try: name = raw_input('請輸入姓名:') age = raw_input('請輸入年齡:') year = raw_input('請輸入年度(民國):') if len(year): year = int(year) else: year = datetime.today().year - 1911 print '=' * 20 htls.htls().all(name, age, year) print '=' * 20 except KeyboardInterrupt: break print '\nbye ...'