Identifying parts within a link and reformat them in the embed - discord.js

I am trying to create command that identifies the sitename and the username from the link. For example using !link https://en.wikipedia.org/wiki/User:Example, !link https://en.wikipedia.org/wiki/Special:Contributions/Example, or !link https://en.wikipedia.org/wiki/User_talk:Example would create an embed of
const embed = new Discord.MessageEmbed()
.setColor('#bf00ff')
.addTitle(`en.wikipedia.org`, [Wiki link](https://en.wikipedia.org/wiki/Main_Page))
.addField(`User info of Example`, `[Userpage](https://en.wikipedia.org/wiki/User:Example) | [User_talk](https://en.wikipedia.org/wiki/User_talk:Example) | [Logs](https://en.wikipedia.org/wiki/Special:Log/Example) | [User groups](https://en.wikipedia.org/wiki/Special:UserRights/Example) | [User contributions](https://en.wikipedia.org/wiki/Special:Contributions/Example) | [BlockLog](https://en.wikipedia.org/w/index.php?title=Special:Log/block&page=User:Example)
message.channel.send(embed)
Also, if the link doesn't have User:, Special:Contributions/, or User_talk:, as well as the sitename (e.g. en.wikipedia.org), and the username within it, then create an error message.
If the link contains ?useskin=monobook, ?useskin=vector, ?useskin=modern, or ?useskin=apex, which is after the username, ignore those part in the link. For example, https://en.wikipedia.org/wiki/User_talk:Example?useskin=vector should be interpreted as https://en.wikipedia.org/wiki/User_talk:Example, and the username should also be interpreted as Example, not Example?useskin=vector
How could I accomplish that?

Related

Missing type property on running https://graph.microsoft.com/v1.0/places

I need to get all the conference rooms and reservable spaces in a tenant.
I believe List Places API is what I need to use (https://learn.microsoft.com/en-us/graph/api/place-list?view=graph-rest-1.0&tabs=http). How do I differentiate between conference rooms and reservable spaces?
I don't see a property in the response that indicates:  '"Type": "Room" or "Space"
In my demo tenant, I created a reservable space by running PowerShell command:  
New-Mailbox xxx -Room | Set-Mailbox -Type Workspace  
On running
Get-Place xxx | fl
I see Type as 'Space'  
 
I created a room by running PowerShell command: 
New-Mailbox yyy -Room
On running
Get-Place yyy | fl
I see Type as 'Room'
However I don't see Type property on running
https://graph.microsoft.com/v1.0/places/
on Graph Explorer. What am I missing?
I have reproduced in my environment and got expected results as below:
Alternatively, you can use microsoft graph as below
AFAIK, there will be no type in output, but if you want to get types such as rooms and spaces you can use below queries:
If you want get the spaces available you can below query:
https://graph.microsoft.com/beta/places/xx.onmicrosoft.com/microsoft.graph.space
To find rooms use below request and I followed Microsoft-Document :
https://graph.microsoft.com/beta/me/findRooms
To get room list you can also use below request and I followed Microsoft-Document:
https://graph.microsoft.com/v1.0/places/microsoft.graph.roomlist

API for getting contact info about College or University?

There are lots of resources for getting name, website, accreditation info, etc for higher education institutions such as the College Scorecard API or IPEDS. What I need for this project is to find a general contact information email address for my set of a few hundred colleges and universities. I plan on using Google Sheets and Apps Script to collect this data.
I have a spreadsheet such as
| Name | URL | City | State | Email |
|-----------------------|----------------------|-----------------|-------|-------|
| Prairie State College | www.prairiestate.edu | Chicago Heights | IL | |
| Langston University | www.langston.edu | Langston | OK | |
where I need to fill in the "email" column. Does anyone know any APIs that could help with that? A quick Google search tells me that ldickerson#prairiestate.edu is the contact at Prairie State College, whereas the admissions page of Langston University has luadmissions#langston.edu right on it. Does anyone have any ideas on where I can pull this data from automatically?
There is no direct API that can help you achieve that.
What you can do instead is to use UrlFetchApp from Apps Script and retrieve the page text from the admission/contact pages wanted. Afterwards you can retrieve the email address from the page text retrieved using regex.
The below code does the mentioned above but depending on the page, it may retrieve more than one email address. If you know exactly that the first email in the list is the email address you actually need, you can call email[0] instead.
function findMail() {
var url ="ADMISSION_CONTACT_PAGE_URL";
var pageText = UrlFetchApp.fetch(url).getContentText();
var email = pageText.match(/([a-zA-Z0-9._-]+#[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]+)/gi);
Logger.log(email);
}
Reference
UrlFetchApp Class Apps Script;
Regex Tester.

Hide text lines/text patterns from a generated logfile

As my role as tester (among all the things), I need to review log files for errors. Unfortunatly, the generated output file (file-YYYY-MM-DD.log) displays all kinds of information, not just the errors (or "things that go bad").
My question is; how do I hide the lines I don't want and generate an output file (log) containing the deviations (errors, warnings etc)?
For example, I want to hide:
| I | variable text I do not want, location: /path/to/foo/bar
| W | service X stopped
| W | service X started
The most ideal outcome with the script I want is:
-> Ask question: "Do you want to hide information and warning messages? |
-> Answer: yes --> hide all | I | message (like: no new foo's found in: /location/to/foo.
-> Answer: no --> do nothing (closes script)
The data is from an Unix environment, however the script is going to run in an Windows environment.
Thanks

Office 365 Powershell - WinForm get-msoldomain as string

I'm playing with WinForms and powershell and am creating a form to create a new user on Office 365 as part of a suite of commonly used tools. For specifying email address I will have a text box for the alias then a dropdown box with available domains.
I'm pulling a list of domains using Get-MSOLDomain
This is my combobox form part.
$form1.Controls.Add($comboBox1)
$cbentries = Get-MsolDomain | select name
foreach ($en in $cbentries) { $comboBox1.Items.Add($en) }
The problem I'm having is that the output of the domains displays as #{Name=domain.com}
How can I get this to only display the domain name not the #{Name= part?
Thanks
You need to pass names only, expand the Name attribute:
$cbentries = Get-MsolDomain | select -expand name
You can also use the foreach-object cmdlet:
$cbentries = Get-MsolDomain | foreach {$_.name}

How to store an array returned by javascript function split in Selenium IDE

Not a developer, new to Selenium IDE, and yes, limited to sticking with IDE only. Appreciate any and all help.
Trying to grab a password from an email generated upon Password Reset so the script can then log in with the new password.
Thought I'd do a split on a delimiter in the email content, Trim as necessary to grab the password. Running into problems with how to store the returned array. In order to do what I'm thinking, I need to store it back into an array that Selenium can traverse.
storeText | css=body | emailText
getEval | storeResults = javascript{storedVars['emailText'].split("delimiter")}
The getEval throws an "missing ; before statement" exception. Using method store instead of getEval works (and moving storeResults to a target), but then the results are typecast as a string. I feel I'm missing something very basic here.
I think the keyword javascript must be omitted
For me the following code works:
storeText | //*[#id="_currentProduct"] | myText
getEval | alert(storedVars['myText'])
When run the alertbox has the value of myText.
Thanks for the response. I came to the same conclusion. Here's the working code:
getEval | storeResults = storedVars['emailText'].split("delimiter")
Was able to access the stored value this way:
LOG.info(storeResults[1])

Resources