Skip to content
← Back to Community
Is there a way to get the username of an account that runs a repl and store it?
Profile icon
Atomic-Gamming

I am trying to make a log of users that run my repl. How would I do it? I have looked all over but no answers?
Can you help me?

Answered by Vandesm14 [earned 5 cycles]
View Answer
Voters
Profile icon
randomcritz
Profile icon
RithvikKandula1
Profile icon
neocryptixalt
Profile icon
Atomic-Gamming
Comments
hotnewtop
Profile icon
Vandesm14

This is not currently possible on repl.it

Profile icon
Atomic-Gamming
Profile icon
RithvikKandula1

You can do:

import os

os.environ['REPL_OWNER']

even if it says repl owner, it shows the name of the person who runs it.

Profile icon
RithvikKandula1

Also i realised that @Atomic-Gamming asked this 2 years ago...

Profile icon
Atomic-Gamming

@RithvikKandula1 ya, its been quite a bit

Profile icon
Platon-The-Bone
Profile icon
didlly

from os import environ

username = environ["REPL_OWNER"]

Profile icon
neocryptixalt

@didlly That only finds the name of the repl owner. Is there a different key for the user? using "USER" makes the variable equal "runner".

Profile icon
didlly

@neocryptixalt No, this get's the name of the user running to the repl, contrary to it's name. If you don't believe me run this repl: https://replit.com/@didlly/Username?v=1

Profile icon
neocryptixalt

@didlly does this only work if you're not an editor? When I run one of my mutiplayer repls, it always prints the name of the owner, not me. I also tried running it from a spotlight page, still didn't work.
EDIT: your repl works, but it the code doesn't work when I import it into mine.

Profile icon
didlly

@neocryptixalt Uh, I don't know why that happens. It works fine for me.

Profile icon
kramboll

@neocryptixalt works for me!

Profile icon
CadenC1

@neocryptixalt It's probably because you're the owner so it's printing your name

Profile icon
neocryptixalt

@CadenC1 no its printing the owner of the repl's name (not me.)

Profile icon
Lolzify

@neocryptixalt must not work for you, never had that happen

Profile icon
WaterZ69

@didlly I think that's only for python how about node js

Profile icon
HoogidyBoogidy

This doesn't have to do with the username thing, but you don't have to type MULTIPLE lines that say, "print()". You can use ONE print() function by using a multi line string:
'''
TEXT GOES HERE
'''

Profile icon
CookieSnowOwl

It is possible, https://replit.com/@RayhanADev/NodeJS-Virus check out this repl(not a virus) by rayhanadev
@JamesGordon1

Profile icon
ash15khng

This isn't possible because repl.it doesn't provide a way for you to get the usernames of people running your code. Not sure why this feature would be useful tho.

Profile icon
RahulChoubey1

@ash15khng idk, finding how many times a certain user clicked a certain button on your site?

Profile icon
nathanmachane

@ash15khng Keeping track of high scores?

Profile icon
Atomic-Gamming

@ash15khng it was to log who ever ran the beta version on a program so I could give them credit and log who sent feedback if they did send any, but that doesn't matter now