Initial commit

Call the api.test and auth.test methods using a token from the file
"token" in the current directory.

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-05-26 09:21:44 -04:00
commit 13050a1486
2 changed files with 31 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
token
*.sw*

29
slackmail.py Normal file
View File

@ -0,0 +1,29 @@
#!/usr/bin/python
# Copyright 2015 (c) Anna Schumaker.
from urllib import request
# TODO: Move the token file outside of code directory
TOKEN = ""
with open("token") as f:
TOKEN = f.read().strip()
def call_method(method, args = dict()):
arglist = []
for (key, value) in args.items():
arglist += ["%s=%s" % (key, value)]
argstr = "&&".join(arglist)
server = "https://slack.com/api/"
with request.urlopen("%s/%s?%s" % (server, method, argstr)) as f:
print(f.read().decode())
def call_method_auth(method, args = dict()):
args['token'] = TOKEN
call_method(method, args)
call_method("api.test")
call_method_auth("auth.test")