chat: finalize speedchat from site

This commit is contained in:
Master Jumblespeed 2015-08-14 18:50:30 -04:00
parent 7b07c84a79
commit 4904b8040c
4 changed files with 52 additions and 9 deletions

2
dependencies/astron/databases/astrondb/.gitignore vendored Normal file → Executable file
View file

@ -1,2 +1,2 @@
* *
!.gitignore !.gitignore

View file

@ -773,3 +773,48 @@ class ToontownRPCHandler(ToontownRPCHandlerBase):
oldFields = {'setWishNameState': 'PENDING'} oldFields = {'setWishNameState': 'PENDING'}
return self.rpc_updateObject( return self.rpc_updateObject(
avId, 'DistributedToonUD', newFields, oldFields=oldFields) avId, 'DistributedToonUD', newFields, oldFields=oldFields)
@rpcmethod(accessLevel=MODERATOR)
def rpc_getChatSettings(self, accId):
"""
Summary:
Retrieves the chat settings of the account associated with the provided
[accId].
Parameters:
[int accId] = The ID of the account whose chat settings
are to be retreived.
Example response:
On success: [uint8[sp+, tf]]
On failure: False
"""
dclassName, fields = self.rpc_queryObject(int(accId))
if dclassName == 'Account':
if 'CHAT_SETTINGS' in fields:
return fields['CHAT_SETTINGS']
# The chat settings haven't been set yet, so we'll
# want to do that now.
self.rpc_setChatSettings(accId)
return [1, 1]
return False
@rpcmethod(accessLevel=MODERATOR)
def rpc_setChatSettings(self, accId, speedChatPlus = 1, trueFriends = 1):
"""
Summary:
Sets the chat settings of the account associated with the provided
[accId].
Parameters:
[int accId] = The ID of the account whose chat settings
are to be changed.
[uint8[sp+, tf]] = The chat settings - SpeedChat Plus and
True Friends
Example response:
On success: True
On failure: False
"""
return self.rpc_updateObject(accId, 'AccountUD', {'CHAT_SETTINGS':
[int(speedChatPlus), int(trueFriends)]})

View file

@ -7,16 +7,13 @@ from panda3d.core import *
username = os.environ['ttsUsername'] username = os.environ['ttsUsername']
password = os.environ['ttsPassword'] password = os.environ['ttsPassword']
accountServerEndpoint = 'http://www.toontownstride.com/api/' accountServerEndpoint = 'https://toontownstride.com/api/'
session = requests.Session() request = requests.post(
csrf_query = session.get(accountServerEndpoint + 'login/')
csrf = session.cookies.get_dict().get('csrftoken', '')
request = session.post(
accountServerEndpoint + 'login/', accountServerEndpoint + 'login/',
data={'username': username, 'password': password, 'csrfmiddlewaretoken': csrf}) data={'username': username, 'password': password, 'distribution': 'qa'})
try: try:
response = json.loads('{'+request.text.split('{', 1)[1]) # so that we ignore the csrf token response = json.loads(request.text)
except ValueError: except ValueError:
print "Couldn't verify account credentials." print "Couldn't verify account credentials."
else: else:

View file

@ -78,7 +78,8 @@ def executeHttpRequest(url, **extras):
_data[k] = v _data[k] = v
signature = hashlib.sha512(json.dumps(_data) + apiSecret).hexdigest() signature = hashlib.sha512(json.dumps(_data) + apiSecret).hexdigest()
data = urllib.urlencode({'data': json.dumps(_data), 'hmac': signature}) data = urllib.urlencode({'data': json.dumps(_data), 'hmac': signature})
req = urllib2.Request('http://www.toontownstride.com/api/' + url, data) req = urllib2.Request('https://toontownstride.com/api/' + url, data,
headers={"Content-Type" : "application/x-www-form-urlencoded"})
req.get_method = lambda: "POST" req.get_method = lambda: "POST"
try: try:
return urllib2.urlopen(req).read() return urllib2.urlopen(req).read()