mirror of
https://github.com/MCMi460/3DS-RPC.git
synced 2025-06-19 05:55:36 -04:00
Big website update
This commit is contained in:
parent
af134d9959
commit
c08ef3e6aa
4
TERMS.md
4
TERMS.md
@ -22,8 +22,10 @@ Due to the nature of this app, it constantly scrapes the bot's friend list and s
|
||||
| `mii` | `text` |
|
||||
| `joinable` | `boolean` |
|
||||
| `gameDescription` | `text` |
|
||||
| `jeuFavori`\* | `bigint` |
|
||||
|
||||
The above objects are scraped and stored by the friend bot.
|
||||
The above objects are scraped and stored by the friend bot.
|
||||
\*`jeuFavori` is the user's favorite game
|
||||
|
||||
<h3 id = 'article2'>How Do I Opt-Out?</h3>
|
||||
|
||||
|
@ -112,21 +112,27 @@ async def main():
|
||||
|
||||
ti.unk2 = 0 # A cursed (but operable) 'hack'
|
||||
try:
|
||||
j1 = await friends_client.get_friend_comment([ti,])
|
||||
j1 = await friends_client.get_friend_persistent_info([ti.unk1,])
|
||||
except:
|
||||
continue
|
||||
comment = j1[0].message
|
||||
jeuFavori = 0
|
||||
username = ''
|
||||
face = ''
|
||||
if not j1[0].comment.endswith(' '):
|
||||
if not comment.endswith(' '):
|
||||
# Get user's mii + username from mii
|
||||
m = await friends_client.get_friend_mii([ti,])
|
||||
username = m[0].mii.unk1
|
||||
mii_data = m[0].mii.mii_data
|
||||
obj = MiiData()
|
||||
obj.decode(obj.convert(io.BytesIO(mii_data)))
|
||||
face = obj.mii_studio()['data']
|
||||
|
||||
# Get user's favorite game
|
||||
jeuFavori = j1[0].game_key.title_id
|
||||
else:
|
||||
j1[0].comment = ''
|
||||
cursor.execute('UPDATE friends SET username = \'%s\', message = \'%s\', mii = \'%s\' WHERE friendCode = \'%s\'' % (username, j1[0].comment, face, str(convertPrincipalIdtoFriendCode(ti.unk1)).zfill(12)))
|
||||
comment = ''
|
||||
cursor.execute('UPDATE friends SET username = \'%s\', message = \'%s\', mii = \'%s\', jeuFavori = \'%s\' WHERE friendCode = \'%s\'' % (username, comment, face, jeuFavori, str(convertPrincipalIdtoFriendCode(ti.unk1)).zfill(12)))
|
||||
con.commit()
|
||||
|
||||
for friend in rotation + cleanUp:
|
||||
|
@ -35,7 +35,7 @@ def handler404(e):
|
||||
# Limiter limits
|
||||
userPresenceLimit = '3/minute'
|
||||
newUserLimit = '2/minute'
|
||||
cdnLimit = '20/minute'
|
||||
cdnLimit = '30/minute'
|
||||
|
||||
# Database files
|
||||
titleDatabase = []
|
||||
@ -157,6 +157,7 @@ def getPresence(friendCode:int, *, créerCompte:bool = True, ignoreUserAgent = F
|
||||
'accountCreation': result[5],
|
||||
'lastAccessed': result[4],
|
||||
'lastOnline': result[11],
|
||||
'favoriteGame': result[12],
|
||||
}
|
||||
}
|
||||
except Exception as e:
|
||||
@ -212,18 +213,40 @@ def settings():
|
||||
response = make_response(render_template('dist/settings.html', data = sidenav()))
|
||||
return response
|
||||
|
||||
# Register page
|
||||
@app.route('/register.html')
|
||||
def register():
|
||||
response = make_response(render_template('dist/register.html'))
|
||||
return response
|
||||
|
||||
# Failure page
|
||||
@app.route('/failure.html')
|
||||
def failure():
|
||||
return render_template('dist/failure.html')
|
||||
|
||||
# Success page
|
||||
@app.route('/success.html')
|
||||
def success():
|
||||
data = {
|
||||
'url': 'user/' + request.args.get('fc'),
|
||||
}
|
||||
return render_template('dist/success.html', data = data)
|
||||
|
||||
@app.route('/user/<string:friendCode>/')
|
||||
def userPage(friendCode:str):
|
||||
try:
|
||||
userData = getPresence(int(friendCode), créerCompte = False, ignoreUserAgent = True, ignoreBackend = True)
|
||||
userData = getPresence(int(friendCode.replace('-', '')), créerCompte = False, ignoreUserAgent = True, ignoreBackend = True)
|
||||
if userData['Exception'] or not userData['User']['username']:
|
||||
raise Exception(userData['Exception'])
|
||||
except:
|
||||
return redirect('/404.html')
|
||||
return render_template('dist/404.html')
|
||||
if userData['User']['online'] and userData['User']['Presence']:
|
||||
userData['User']['Presence']['game'] = getTitle(userData['User']['Presence']['titleID'], titlesToUID, titleDatabase)
|
||||
else:
|
||||
userData['User']['Presence']['game'] = None
|
||||
userData['User']['favoriteGame'] = getTitle(userData['User']['favoriteGame'], titlesToUID, titleDatabase)
|
||||
if userData['User']['favoriteGame']['name'] == 'Home Screen':
|
||||
userData['User']['favoriteGame'] = None
|
||||
for i in ('accountCreation','lastAccessed','lastOnline'):
|
||||
if userData['User'][i] == 0:
|
||||
userData['User'][i] = 'Never'
|
||||
@ -250,9 +273,10 @@ def terms():
|
||||
# Create entry in database with friendCode
|
||||
@app.route('/api/user/create/<int:friendCode>/', methods=['POST'])
|
||||
@limiter.limit(newUserLimit)
|
||||
def newUser(friendCode:int):
|
||||
def newUser(friendCode:int, userCheck:bool = True):
|
||||
try:
|
||||
userAgentCheck()
|
||||
if userCheck:
|
||||
userAgentCheck()
|
||||
createUser(friendCode, True)
|
||||
return {
|
||||
'Exception': False,
|
||||
@ -302,6 +326,16 @@ def cdnImage(file:str):
|
||||
response.headers['Content-Type'] = 'image/jpeg'
|
||||
return response
|
||||
|
||||
# Login route
|
||||
@app.route('/login', methods=['POST'])
|
||||
def login():
|
||||
try:
|
||||
fc = str(convertPrincipalIdtoFriendCode(convertFriendCodeToPrincipalId(request.form['fc']))).zfill(12)
|
||||
newUser(fc, False)
|
||||
except:
|
||||
return redirect('/failure.html')
|
||||
return redirect(f'/success.html?fc={fc}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
cacheTitles()
|
||||
if local:
|
||||
|
@ -10,7 +10,8 @@ Create Table friends(
|
||||
mii text,
|
||||
joinable boolean,
|
||||
gameDescription text,
|
||||
lastOnline bigint NOT NULL
|
||||
lastOnline bigint NOT NULL,
|
||||
jeuFavori bigint NOT NULL
|
||||
);
|
||||
|
||||
Create Table config(
|
||||
|
@ -27,7 +27,6 @@ html(lang='en')
|
||||
include includes/head/title.pug
|
||||
include includes/head/css.pug
|
||||
include includes/head/icons.pug
|
||||
include includes/navigation/topnav.pug
|
||||
|
||||
body(style="background-image: url({{ url_for('static',filename='assets/img/background.png') }}); background-repeat: no-repeat; background-size: cover;")
|
||||
|
||||
|
@ -12,16 +12,10 @@ nav.sb-topnav.navbar.navbar-expand.navbar-dark(id = 'topnav')
|
||||
form.d-none.d-md-inline-block.form-inline.ms-auto.me-0.me-md-3.my-2.my-md-0
|
||||
|
||||
// What was once the account toolbar...
|
||||
//-ul.navbar-nav.ms-auto.ms-md-0.me-3.me-lg-4
|
||||
ul.navbar-nav.ms-auto.ms-md-0.me-3.me-lg-4
|
||||
li.nav-item.dropdown
|
||||
a#navbarDropdown.nav-link.dropdown-toggle(href='#' role='button' data-bs-toggle='dropdown' aria-expanded='false')
|
||||
i.fas.fa-user.fa-fw
|
||||
ul.dropdown-menu.dropdown-menu-end(aria-labelledby='navbarDropdown')#accountSymbol
|
||||
ul.dropdown-menu.dropdown-menu-end(aria-labelledby='navbarDropdown')
|
||||
li
|
||||
a.dropdown-item(href='settings.html') Settings
|
||||
li
|
||||
a.dropdown-item(href='activity.html') Activity Log
|
||||
li
|
||||
hr.dropdown-divider
|
||||
li
|
||||
a.dropdown-item(href='logout') Logout
|
||||
a.dropdown-item(href='register.html') Register
|
||||
|
11
server/templates/src/pug/pages/failure.pug
Normal file
11
server/templates/src/pug/pages/failure.pug
Normal file
@ -0,0 +1,11 @@
|
||||
extends ../layouts/error.pug
|
||||
|
||||
block content
|
||||
.container
|
||||
.row.justify-content-center
|
||||
.col-lg-6
|
||||
.text-center.mt-4
|
||||
p.lead Something went wrong! But what?
|
||||
a(href='/')
|
||||
i.fas.fa-arrow-left.me-1
|
||||
| Return to Home
|
@ -1,5 +1,13 @@
|
||||
// Optionally, add white background to here as well. card.mb-X
|
||||
h1.mt-4 #{pageTitle}
|
||||
if index || settings
|
||||
h1.mt-4 #{pageTitle}
|
||||
else
|
||||
h1.mt-4
|
||||
| #{pageTitle}
|
||||
small(style = 'font-size: 0.7em;')#splitTHIS #{fc}
|
||||
script.
|
||||
let x = document.getElementById('splitTHIS');
|
||||
x.textContent = '(' + (x.textContent.match(/.{1,4}/g) ?? []).join('-') + ')';
|
||||
if index
|
||||
ol.breadcrumb.mb-4
|
||||
li.breadcrumb-item.active #{pageTitle}
|
||||
|
26
server/templates/src/pug/pages/register.pug
Normal file
26
server/templates/src/pug/pages/register.pug
Normal file
@ -0,0 +1,26 @@
|
||||
extends ../layouts/authentication.pug
|
||||
|
||||
block config
|
||||
- var pageTitle = 'Register'
|
||||
|
||||
|
||||
|
||||
block content
|
||||
.container
|
||||
|
||||
.row.justify-content-center
|
||||
.col-lg-6
|
||||
.card.shadow-lg.border-0.rounded-lg.mt-5
|
||||
.card-header
|
||||
h3.text-center.font-weight-light.my-4 Register
|
||||
.card-body
|
||||
form(action = '/login', method = 'POST')
|
||||
.form-floating.mb-3
|
||||
input#inputFC.form-control(type = 'text', placeholder = '1234-5678-9012', name = 'fc', value = '')
|
||||
label(for = 'inputFC') Friend Code
|
||||
.d-flex.align-items-center.justify-content-end.mt-4.mb-0
|
||||
input.btn.btn-primary(type = 'submit', value = 'Login')
|
||||
.card-footer.text-center
|
||||
.small
|
||||
| By using this service, you agree to the
|
||||
a(href='/terms') Terms and Services
|
@ -1,17 +1,19 @@
|
||||
extends ../layouts/authentication.pug
|
||||
extends ../layouts/dashboard.pug
|
||||
|
||||
block config
|
||||
- var pageTitle = 'Settings'
|
||||
|
||||
|
||||
- var bodyClass = 'sb-nav-fixed'
|
||||
- var pageTitle = "Settings"
|
||||
- var sidenavStyle = 'sb-sidenav-dark'
|
||||
- var settings = true;
|
||||
|
||||
block content
|
||||
.container
|
||||
.row.justify-content-center
|
||||
.container-fluid.px-4
|
||||
include includes/page-header.pug
|
||||
|
||||
.d-flex.justify-content-center
|
||||
.col-lg-10
|
||||
.card.shadow-lg.border-0.rounded-lg.mt-5
|
||||
.card.text-center
|
||||
.card-header
|
||||
h3.text-center.font-weight-light.my-4 Settings
|
||||
b Settings
|
||||
.card-body
|
||||
| These are some settings!
|
||||
|
||||
| There's nothing here!
|
||||
|
15
server/templates/src/pug/pages/success.pug
Normal file
15
server/templates/src/pug/pages/success.pug
Normal file
@ -0,0 +1,15 @@
|
||||
extends ../layouts/error.pug
|
||||
|
||||
block content
|
||||
.container
|
||||
.row.justify-content-center
|
||||
.col-lg-6
|
||||
.text-center.mt-4
|
||||
h3 Your account has been created!
|
||||
p.lead But it'll take a minute or two for your profile to be loaded.
|
||||
a(href='/{{ data["url"] }}')
|
||||
| Try Profile
|
||||
br
|
||||
a(href='/')
|
||||
i.fas.fa-arrow-left.me-1
|
||||
| Return to Home
|
@ -3,51 +3,67 @@ extends ../layouts/dashboard.pug
|
||||
block config
|
||||
- var bodyClass = 'sb-nav-fixed'
|
||||
- var pageTitle = "{{ data['User']['username'] }}"
|
||||
- var fc = "{{ data['User']['friendCode'] }}"
|
||||
- var sidenavStyle = 'sb-sidenav-dark'
|
||||
|
||||
block content
|
||||
.container-fluid.px-4
|
||||
include includes/page-header.pug
|
||||
|
||||
html {% if data['User']['Presence']['game'] %}
|
||||
.modal.fade#gameInfo(tabindex = '-1', aria-labelledby = 'modelLabel', aria-hidden = 'true')
|
||||
html {% for game in (data['User']['Presence']['game'], data['User']['favoriteGame']) %}
|
||||
html {% if game %}
|
||||
.modal.fade(tabindex = '-1', aria-labelledby = 'modelLabel', aria-hidden = 'true')
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
h5.modal-title#modalLabel
|
||||
b {{ data['User']['Presence']['game']['name'] }}
|
||||
| by {{ data['User']['Presence']['game']['publisher']['name'] }}
|
||||
b {{ game['name'] }}
|
||||
| by {{ game['publisher']['name'] }}
|
||||
button.btn-close(type = 'button' data-bs-dismiss = 'modal' aria-label = 'Close')
|
||||
.modal-body
|
||||
div
|
||||
img(src = "{{ data['User']['Presence']['game']['banner_url'] }}", style = "height: 100%; width: 100%;")
|
||||
img(src = "{{ game['banner_url'] }}", style = "height: 100%; width: 100%;")
|
||||
div.d-flex.justify-content-between
|
||||
div Genre: {{ data['User']['Presence']['game']['display_genre'] }}
|
||||
div Genre: {{ game['display_genre'] }}
|
||||
div Rating:
|
||||
b {{ data['User']['Presence']['game']['star_rating_info']['score'] }}/5
|
||||
b {{ game['star_rating_info']['score'] }}/5
|
||||
| Stars
|
||||
div.d-flex.justify-content-between
|
||||
div Price: {{ data['User']['Presence']['game']['price_on_retail'] }}
|
||||
div Price: {{ game['price_on_retail'] }}
|
||||
div Released:
|
||||
b {{ data['User']['Presence']['game']['release_date_on_eshop'] }}
|
||||
b {{ game['release_date_on_eshop'] }}
|
||||
.modal-footer
|
||||
html {% if data['User']['Presence']['game']['name'] != 'Home Screen' %}
|
||||
button.btn.btn-secondary(type = 'button' onclick = "window.open(`https://www.google.com/search?q={{ '+'.join((data['User']['Presence']['game']['name'] + ' ' + data['User']['Presence']['game']['publisher']['name']).split(' ')) }}`, `_blank`);") Search Online
|
||||
html {% if game['name'] != 'Home Screen' %}
|
||||
button.btn.btn-secondary(type = 'button' onclick = "window.open(`https://www.google.com/search?q={{ '+'.join((game['name'] + ' ' + game['publisher']['name']).split(' ')) }}`, `_blank`);") Search Online
|
||||
html {% endif %}
|
||||
button.btn.btn-primary(type = 'button' data-bs-dismiss = 'modal') Close
|
||||
html {% else %}
|
||||
.modal.fade(tabindex = '-1', aria-labelledby = 'modelLabel', aria-hidden = 'true')
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-footer
|
||||
button.btn.btn-primary(type = 'button' data-bs-dismiss = 'modal') Close
|
||||
html {% endif %}
|
||||
html {% endfor %}
|
||||
|
||||
script.
|
||||
let f = document.getElementsByClassName('modal');
|
||||
for (let i = 0; i < f.length; i++)
|
||||
{
|
||||
f[i].id = 'ID' + i.toString();
|
||||
}
|
||||
|
||||
.row
|
||||
.col-sm-2.d-flex.align-items-end
|
||||
img(src = "{{ data['User']['mii']['face'] }}", width = '100%', style = 'background: linear-gradient(0deg, rgb(255, 198, 147) 0%, rgb(254, 245, 239, 0.1) 100%);')
|
||||
.col-md-5
|
||||
.row(style = 'padding-top: 25px')
|
||||
.row(style = 'padding-top: 2rem;')
|
||||
.card.text-center
|
||||
html {% if data['User']['Presence']['game'] %}
|
||||
.card-header(style = 'background-color: inherit;')
|
||||
| Currently playing...
|
||||
b CURRENTLY PLAYING
|
||||
html {% endif %}
|
||||
a.card-body.d-flex.align-items-center.text-black(style = 'text-decoration: none;', data-bs-toggle="modal", href = '#gameInfo')
|
||||
a.card-body.d-flex.align-items-center.text-black(style = 'text-decoration: none;', data-bs-toggle="modal", href = '#ID0')
|
||||
html {% if data['User']['Presence']['game'] %}
|
||||
.col-md-2
|
||||
img(src = "{{ data['User']['Presence']['game']['icon_url'] }}", width = '100%')
|
||||
@ -66,30 +82,35 @@ block content
|
||||
html {% endif %}
|
||||
.row
|
||||
html {% if data['User']['message'] %}
|
||||
.col-xl-2(style = 'padding-top: 25px')
|
||||
.col-xl-2(style = 'padding-top: 2rem')
|
||||
.card
|
||||
.card-header(style = 'background-color: inherit;')
|
||||
.card-header
|
||||
b STATUS
|
||||
.card-body
|
||||
| {{ data['User']['message'] }}
|
||||
html {% endif %}
|
||||
.col-xl-2(style = 'padding-top: 25px')
|
||||
.col-xl-2(style = 'padding-top: 2rem')
|
||||
.card
|
||||
.card-header(style = 'background-color: inherit;')
|
||||
.card-header
|
||||
b MEMBER SINCE
|
||||
.card-body
|
||||
| {{ data['User']['accountCreation'] }}
|
||||
.col-xl-2(style = 'padding-top: 25px')
|
||||
.col-xl-2(style = 'padding-top: 2rem')
|
||||
.card
|
||||
.card-header(style = 'background-color: inherit;')
|
||||
.card-header
|
||||
b LAST ONLINE
|
||||
.card-body
|
||||
| {{ data['User']['lastOnline'] }}
|
||||
.row.d-flex.justify-content-between(style = 'padding-top: 2rem;')
|
||||
.col-xl-7
|
||||
.card
|
||||
.card-header(style = 'background-color: inherit;')
|
||||
i.fas.fa-chart-area.me-1
|
||||
| Activity Log
|
||||
.card-body
|
||||
|
||||
.row(style = 'padding-top: 2rem; padding-bottom: 2rem;')
|
||||
.col-xl-6
|
||||
.card
|
||||
.card-header
|
||||
b FAVORITE GAME
|
||||
a.card-body.d-flex.align-items-center.text-black(style = 'text-decoration: none;', data-bs-toggle="modal", href = '#ID1')
|
||||
html {% if data['User']['favoriteGame'] %}
|
||||
.col-md-2
|
||||
img(src = "{{ data['User']['favoriteGame']['icon_url'] }}", width = '100%')
|
||||
p(style = 'padding-left: 1rem;') {{ data['User']['favoriteGame']['name'] }}
|
||||
html {% else %}
|
||||
.text-muted.text-center None
|
||||
html {% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user