mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-23 03:35:12 -06:00
chat: finalize speedchat from site
This commit is contained in:
parent
7b07c84a79
commit
4904b8040c
4 changed files with 52 additions and 9 deletions
2
dependencies/astron/databases/astrondb/.gitignore
vendored
Normal file → Executable file
2
dependencies/astron/databases/astrondb/.gitignore
vendored
Normal file → Executable file
|
@ -1,2 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
||||
!.gitignore
|
|
@ -773,3 +773,48 @@ class ToontownRPCHandler(ToontownRPCHandlerBase):
|
|||
oldFields = {'setWishNameState': 'PENDING'}
|
||||
return self.rpc_updateObject(
|
||||
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)]})
|
||||
|
|
|
@ -7,16 +7,13 @@ from panda3d.core import *
|
|||
username = os.environ['ttsUsername']
|
||||
password = os.environ['ttsPassword']
|
||||
|
||||
accountServerEndpoint = 'http://www.toontownstride.com/api/'
|
||||
session = requests.Session()
|
||||
csrf_query = session.get(accountServerEndpoint + 'login/')
|
||||
csrf = session.cookies.get_dict().get('csrftoken', '')
|
||||
request = session.post(
|
||||
accountServerEndpoint = 'https://toontownstride.com/api/'
|
||||
request = requests.post(
|
||||
accountServerEndpoint + 'login/',
|
||||
data={'username': username, 'password': password, 'csrfmiddlewaretoken': csrf})
|
||||
data={'username': username, 'password': password, 'distribution': 'qa'})
|
||||
|
||||
try:
|
||||
response = json.loads('{'+request.text.split('{', 1)[1]) # so that we ignore the csrf token
|
||||
response = json.loads(request.text)
|
||||
except ValueError:
|
||||
print "Couldn't verify account credentials."
|
||||
else:
|
||||
|
|
|
@ -78,7 +78,8 @@ def executeHttpRequest(url, **extras):
|
|||
_data[k] = v
|
||||
signature = hashlib.sha512(json.dumps(_data) + apiSecret).hexdigest()
|
||||
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"
|
||||
try:
|
||||
return urllib2.urlopen(req).read()
|
||||
|
|
Loading…
Reference in a new issue