import requests
import json
global data
import sys
import re
import os
import getpass
from bs4 import BeautifulSoup

def checkFriends(userid1, userid2):
    r = requests.get("https://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerId="+str(userid1)+"&userId="+str(userid2))
    if "true" in r.text:
        return True
    else:
        return False
def userInGroup(mode, userid, groupid):
    #modes: GetGroupRank (number of rank), IsInGroup, GetGroupRole (rank name)
    r = requests.get("https://www.roblox.com/Game/LuaWebService/HandleSocialRequest.ashx?method="+str(mode)+"&playerid="+str(userid)+"&groupid="+str(groupid))
    if mode == "GetGroupRank":
        r2 = r.text[22:]
        r3 = r2.split("<")
        r4 = r3[0]
        return str(r4)
    if mode == "IsInGroup":
        if "true" in r.text:
            return True
        else:
            return False
    if mode == "GetGroupRole":
        return r.text
def userOwnsAsset(userid, assetid):
    r = requests.get("https://api.roblox.com/Ownership/HasAsset?userId="+str(userid)+"&assetId="+str(assetid))
    if "false" in r.text:
        return False
    else:
        return True
def usernameTaken(username):
    r = requests.get("https://www.roblox.com/UserCheck/DoesUsernameExist?username="+str(username))
    if "true" in r.text:
        return True
    else:
        return False
def getPrimaryGroupInfo(mode, username):
    try:
        r = requests.get("https://www.roblox.com/Groups/GetPrimaryGroupInfo.ashx?users="+str(username))
    except requests.exceptions.RequestException as e:
        print("")
        print("An connection error has occured, details below.")
        print("")
        print(e)
        print("")
        sys.exit(1)
    if mode == "GroupId":
        data = r.json()
        username1 = str(username)
        return data[username1]['GroupId']
    if mode == "GroupName":
        data = r.json()
        username1 = str(username)
        return data[username1]['GroupName']
    if mode == "GroupRole":
        data = r.json()
        username1 = str(username)
        return data[username1]['RoleSetName']
    else:
        print("An error has occured, please check spelling.")
def getPackageIds(packageid):
    try:
        r = requests.get("https://web.roblox.com/Game/GetAssetIdsForPackageId?packageId="+str(packageid))
        a = r.text
        return a
    except Exception as e:
        print("")
        print("A error has occured, please see below.")
        print("")
        print(e)
def postLogin(username):
    password = getpass.getpass('ROBLOX Account Password: ')
    try:
        r = requests.post("https://www.roblox.com/NewLogin", data={"username":str(username),"password":password})
        print("Logged in.")
        return r.status_code
    except requests.exceptions.RequestException as e:
        print("")
        print("A error has occured, please see below. Please note, this does not work with 2-Step Verification accounts yet.")
        print("")
        print(e)
def getRecommendedUsername(username):
    try:
        r = requests.get("https://web.roblox.com/UserCheck/GetRecommendedUsername?usernameToTry="+str(username))
        a = r.text
        return a
    except requests.exceptions.RequestException as e:
        print("")
        print("A error has occured, please see below.")
        print("")
        print(e)
def postJoinGroup(username, groupid, *password):
    try:
        if password:
            s = requests.session()
            r = s.post("https://www.roblox.com/NewLogin", data={"username":str(username),"password":password})

            page = s.get('http://www.roblox.com/groups/group.aspx?gid='+str(groupid))
            soup=BeautifulSoup(page.content, "lxml")
            VIEWSTATE=soup.find(id="__VIEWSTATE")['value']
            VIEWSTATEGENERATOR=soup.find(id="__VIEWSTATEGENERATOR")['value']
            EVENTVALIDATION=soup.find(id="__EVENTVALIDATION")['value']

            join = s.get('http://www.roblox.com/groups/group.aspx?gid='+str(groupid), data=dict(__EVENTTARGET="JoinGroupDiv", __EVENTARGUMENT="Click", __LASTFOCUS="", __VIEWSTATE=VIEWSTATE, __VIEWSTATEGENERATOR=VIEWSTATEGENERATOR, __EVENTVALIDATION=EVENTVALIDATION), allow_redirects=True)
            print("Sent group request.")
        else:
            password = getpass.getpass('ROBLOX Account Password: ')
            s = requests.session()
            r = s.post("https://www.roblox.com/NewLogin", data={"username":str(username),"password":password})

            page = s.get('http://www.roblox.com/groups/group.aspx?gid='+str(groupid))
            soup=BeautifulSoup(page.content, "lxml")
            VIEWSTATE=soup.find(id="__VIEWSTATE")['value']
            VIEWSTATEGENERATOR=soup.find(id="__VIEWSTATEGENERATOR")['value']
            EVENTVALIDATION=soup.find(id="__EVENTVALIDATION")['value']

            join = s.get('http://www.roblox.com/groups/group.aspx?gid='+str(groupid), data=dict(__EVENTTARGET="JoinGroupDiv", __EVENTARGUMENT="Click", __LASTFOCUS="", __VIEWSTATE=VIEWSTATE, __VIEWSTATEGENERATOR=VIEWSTATEGENERATOR, __EVENTVALIDATION=EVENTVALIDATION), allow_redirects=True)
            print("Sent group request.")
    except requests.exceptions.RequestException as e:
        print("")
        print("A error has occured, please see below. Please note, this does not work with 2-Step Verification accounts yet.")
        print("")
        print(e)

@@ -79,16 +79,34 @@
 getpass%0A
+import datefinder%0A
 from bs4
@@ -5425,28 +5425,402 @@
  print(%22%22)%0A        print(e)%0A
+def userJoinDate(userid):%0A    r = requests.get(%22https://web.roblox.com/users/%22+str(userid)+%22/profile%22)%0A    text = r.text%0A    for item in text.split('%3C/p%3E'):%0A        if '%3Cp class=%22text-lead%22%3E' in item:%0A            userjoin = datefinder.find_dates(item %5B item.find('%3Cp class=%22text-lead%22%3E')+len('%3Cp%3E') : %5D)%0A            for userdate in userjoin:%0A                return userdate%0A

Update robloxlib.py