serbanghita / Mobile-Detect

Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
http://mobiledetect.net
MIT License
10.52k stars 2.67k forks source link

[Feature Request] Detect command line user agents like curl, wget, PowerShell #924

Open asheroto opened 1 year ago

asheroto commented 1 year ago

I think a great feature to add to Mobile-Detect would be to detect if the user agent is command line based such as curl, wget, PowerShell, etc. That way you could use a command like isCommandLine() or isTextBased() or isCLI().

As an example to illustrate the purpose, the website https://qrenco.de shows up as a regular website in a browser, but if you issue the command curl qrenco.de/https://github.com in your CLI it responds with a QR code. I was thinking - did they use a library to detect that? I don't see the option in Mobile-Detect, so I thought I'd suggest it. 😊

Here is a list of 149 well known user agents that are command line based: https://gist.github.com/asheroto/ef04c4f067be68bd770395a32967811d

DrLightman commented 1 year ago

I think that would go out fo the scope of the plugin. It's not meant to be a full rounded detection plugin. The detection you wrote about can be done with a couple of lines of code of php

asheroto commented 1 year ago

Ah, I see. Is that also why isBot() was removed from later releases?

DrLightman commented 1 year ago

it's possibile, but I'm not sure, I didn't even know :D