Mercurial > prosody-modules
view mod_auth_external/examples/python/prosody-auth-example.py @ 2407:be08b65f2855
mod_log_messages_sql: In 0.10ish, use 'messages' as default table name, override using 'log_messages_sql_table' if needed
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 02 Dec 2016 19:06:37 +0000 |
parents | f5eadba27120 |
children |
line wrap: on
line source
#!/usr/bin/env python2 import sys def auth(username, password): if username == "someone": return "1" return "0" def respond(ret): sys.stdout.write(ret+"\n") sys.stdout.flush() methods = { "auth": { "function": auth, "parameters": 2 } } while 1: line = sys.stdin.readline().rstrip("\n") method, sep, data = line.partition(":") if method in methods: method_info = methods[method] split_data = data.split(":", method_info["parameters"]) if len(split_data) == method_info["parameters"]: respond(method_info["function"](*split_data)) else: respond("error: incorrect number of parameters to method '%s'"%method) else: respond("error: method '%s' not implemented"%method)