Java Discord bot, #mention a user? - java

There doesn't seem to be much about this on google aside from advising to use their userID (a string of numbers) instead of their name.
I enabled dev mode to grab their ID and tried the below however it just comes out as a plain text message with no #mention.
chan.sendMessage("Hey #299059199160352768 are you there?").queue();
Any ideas?

Just add an opening and closing angle bracket. <#id>. So your string would look like
chan.sendMessage("Hey <#299059199160352768> are you there?").queue();

Related

Printing in android studio - folding sections

When I was printing java code in Eclipse, the way of printing was WYSIWYG. So if I folded some selected sections (for example import section, but also any other foldable section), it was printed as folded.
In Android Studio code is printed allways fully unfolded. Does anybody know some way (plugin or some preferences setting etc.), how to set it to print also in the folding WYSIWYG style?
My problem is that I have done the printing part in android device when the printer is already configured on the device.
If the printer is not configured on the device, the exception occurs can you tell that how u know that printer is configured on device
e1=(EditText) findViewById(R.id.editText);
String name=e1.getText().toString();
PrintManager printManager=(PrintManager) this.getSystemService(Context.PRINT_SERVICE);
//PrintDocumentAdapter printAdapter = view.createPrintDocumentAdapter();
//Toast.makeText(getApplicationContext(),"hi nikhil"+name+""+printManager.getPrintJobs(),Toast.LENGTH_LONG).show();
String text=this.getString(R.string.app_name)+"Document";
// printManager.getPrintJobs();
printManager.print(text, new MyPrintDocumentAdapter(this), null);
Log.d("print", "print" + printManager);
on Android-Studio 4.0, I noticed that you can select the parts of a file you wish to print, and in the print dialog box, it will allow you to just print the selection. This isn't exactly what you're looking for, but it is a way to bypass the long lines of import statements and comments at the head of a file.

Using Selenium to access a commercial database with HTTPS security

Half year before. I already accessed to Factva.com(A NEWS DATABASE WITH ACCESS CONTROL) by Selenium driver,searching news automatically. However, two months ago, Factiva updates its access protocol from HTTP to HTTPS, which disables my program.
Under HTTP, my program can switch to a new URL within the same Chrome(EVEN a new tab). I did this by using the function: chrome.get(URL) where the URL is a direct search link. I even access the new search request by this method. You know, under HTTP search, you can just combine some key words and logic operator to produce a new URL. And I use chrome.get(URL) to switch to the new search results.
However, under HTPPS, I cannot use the above method anymore. When I use the method, Factiva shows the infos that I was in the off-login status( I should login again. Even though if I click the backforward button with my mouse, I can go back to the Factiva webpage and need not login)
My question is: Why my old method didn't work UNDER HTTPS? How can I let Factiva know, even I use the old method, I am already in the access and need not login again!
My old method under HTTP:
Class SearchTXT{
public String getSearchUrl(String keyword, String startTime, String endTime){
String f0=”http://global.factiva.com.***.uk/zhcn/du/headlines.asp?napc=S&searchText=”
String f2="&dateRangeMenu=custom&dateFormat=dmy&dateFrom=";
String f4="&dateTo=";
String f6="&sortBy=y&currentSources=";
String f7=”Wall Street Journal”;
String f8="&searchLanguage=custom&searchLang=EN&dedupe=0&srchuiver=2&accountid=9MEM000300&namespace=16";
Return f0+keyword+f2+startTime+f4+endTime+f6+f7+f8;
}
}
AFTER login the FACTIVA database by Selenium Driver, I got a chrome with the access to FACTIVA.
Then: I use this:
SearchTXT st = new SearchTXT():
String searchURL= st.geSearchUrl(“DELL”, “2011-11-10”, “2014-10-10”);
chrome.get(searchURL);
String pageSource=chrome.getPageSource();
Then I can use Jsoup.jar to Parser and collect the search results.
But this method never works after the updating from HTTP to HTTPS. These days I am so annoying about this problem.
Are there some alternative methods that can access the data under HTTPS? Maybe there are some tricks that can make my old method work again. Otherwise, I have to totally modify my whole key program and use JavascriptExecutor to deal with this problem. That means a heavy work. The worst is that the javascript code on FACTIVA website is very complicated. Some key javascript codes and functions are even not shown on the FACTIVA page source directly.
Thanks a LOT!

How could I ensure that Expect will match login prompt everytime?

I am working on a tool that uses telnet to login to a Nortel DMS switch. The switch is quite old and there is no API or anything to tap in order to login.
So in order to pass login data to the system I am using expect4j (yes I am writing in Java).
This is what the login page looks like.
Telnet CHARACTER MODE. <--- This is part of it
Enter User Name
>
[Return key pressed]
Enter Password
>
I was thinking I could use a simple regex. Would I want to match with a \n or is there a better way?

Create an HTML link or button to add an event to a Lotus Notes user's calendar

My client uses Lotus Notes for calendering. We have a need to serve event information on SharePoint. I'm trying to create an HTML link or button I can use in a custom display form on SharePoint (HTML) that users can click to add the event to their Notes calendars. So far, I've found no way to do this.
An app exists on my client's Domino deployment(?) that creates buttons for use in Notes email messages that also can collect response information. The action of this button is handled by what looks like Java to me. I've included a sample in case it's relevant, and I can include all of it if it looks like it would be helpful, but it's quite long:
Set CurDb=Session.CurrentDatabase
'Get mail file information from Location document using Notes.ini
MailServer$ = session.GetEnvironmentString( "MailServer",True)
MailFile$ = session.GetEnvironmentString( "MailFile",True)
'Set MailDB = session.CurrentDatabase
If CurDb.Server = "" Then
'Attempt to open local mail file
Set MailDB = session.GetDatabase("", MailFile$)
If Not MailDB.IsOpen Then
Set MailDB = New NotesDatabase(MailServer$, MailFile$)
If Not MailDB.IsOpen Then
Msgbox "Unable to add event to your calendar because your local and server mail file cannot be located.",16, "Notice"
Exit Sub
End If
End If
Else
'Attempt to open server replica of mail file
Set MailDB = New NotesDatabase(MailServer$, MailFile$)
If Not MailDB.IsOpen Then
Msgbox "Unable to add event to your calendar because your server mail file cannot be located.",16, "Notice"
Exit Sub
End If
End If
The same app can create a "web" version that can be added to our current intranet platform, but it uses what looks to me like a custom "hook" to interact with the button application and the user's calendar, and it has no function if not placed within an object on that platform. I include the snippet here in case it offers a clue:
<input type="button" onclick="SendEmailNotification('PTHN-132512')"
value="Send me a Notes Calendar Invitation" id="HTMLWebBtn">
I'm wondering if using the snippet elsewhere is as easy as linking to a .js file in my source, and am waiting to hear back from people managing the platform internally, but experience says this is a dead end.
Searching on the Googlybox has so far been basically fruitless. I know you can have a link open Lotus Notes by replacing the http:// with Notes:// followed by the server's name and the application/database/document address (usually a sometimes-really-long string of alphanumeric characters). And I found an article containing strings you can place after the Notes:// to open a new document in a given application, i.e., the email editor. But that's as close as I've come.
Any help, folks?
You can leverage the fact that Notes supports the .ics file format. When a ICS file is opened, Notes can respond by creating a new calendar entry. The best thing is that this works in other mail platforms too, in case your environment is mixed.
Here is some info on setting up Notes: http://www.ibm.com/developerworks/lotus/library/notes85-icalendar/
You can programmatically generate that ICS file, or if you're looking to just play around there are sites online that will generate one for you:
http://www.pratie.com/lab/icalendar/

what is the best way to display website visitors a one time welcome message?

I've got a website, and I want to add a welcoming message which hovers on a certain part of the page which only loads for the visitor for the first time they login, and won't again(presumably cookies used). And says something like "adjust your settings here.."
I don't want it to be an external popup but something that loads on the page in a certain area, defined by me (PX-pixle reference)
What would be the best coding language to do it in, oes anyone have any examples of this, or any site based generators to make it on?
thanks
Create one more field in database with lastlogin.
When user is created then make lastlogin field with special.
When user signs the next time from Login Page, update the field the lastlogin value to regular
//query to get value of lastlogin
//add css to elements you want to hover
<element class="<?php if($last-login == 'sepcial') { echo 'sepcialcss'; } else {echo 'regularcss'; }">
Done in PHP
As you added the tag, php would do this, actually any language will do.
Generally you have two ways to do this.
Do it on your server.
Do it on client's computer.
for the first way, you check the cookies and generate the page you want.
for the second way, you need to arrange the page the visitors see with java script.
way 1 recommended, coz it loads less bits. LOL
Update:
your server supports php right? the page, say it index.php, has a special area which is different when the visitors login the first time, right?
<?php
if (firstLogin()){
genSpecial();
}
else{
genRegular();
}
?>
in the funcition firstLogin(), you shall read the cookies and determine.
in the other two functions, just gen two different part, i.e. some html source code.
to your question, if you need to load some image, do it in genSpecial(). and if you choose the first way, js is not used to gen the special area, it's used only if in the special area, there needs some js.
It is possible through javascript. Once the user is shown the settings, store the result in a cookie valid for as long as you want. The next time the user logs in, verify if the cookie is set and then proceed.
Sample code to create cookies:
function setCookie(c_name,value,exdays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
document.cookie=c_name + "=" + c_value;
}
Refer this for more details on how to create and use cookies

Categories