So, I'm trying to change the nickname on the bot to the username of the command sender (?) So here is what I got going now but it changes the name to the id of the user?
commands.CreateCommand("tts")
.Parameter("userMsg", ParameterType.Unparsed)
.Do(async (e) =>
{
var server = _client.GetServer(*server id*);
var user = server.GetUser(_client.CurrentUser.Id);
await user.Edit(nickname: e.User.Mention);
string UserMsg = e.GetArg("userMsg");
await e.Channel.SendTTSMessage(UserMsg);
});
}
What I got going now only changes the bots name to the userid but I don't want that? I've also tried to search around but can't really find anything?
Thanks in advance!
Change e.User.Mention to e.User.Name
Related
I've google for several hours now and I haven't found a suitable solution to my "problem". My previous solution was to use an url like this for fetching json-data of images related to my Instagram account.
https://www.instagram.com/[account-name-here]/media
For some reason this url doesn't work any more (404?). Perhaps Instagram has done some changes on their side.
That in mind I've searched for an alternative solution, with no luck.
I'm super exited to hear if any of you guys can point me in the right direction.
And ... I'm using C# :-)
You can create a client i have an example here
public async Task<object> GetMediaInfo(string mediaId)
{
string clientId = "YOUR_CLIENT_ID";
string clientSecret = "YOUR_CLIENT_SECRET";
string accessToken = "A_VALID_ACCESS_TOKEN";
InstagramClient client = new InstagramClient(clientId,clientSecret);
var media = await client.MediaEndpoints.GetMediaInfoAsync(mediaId, accessToken);
//I use Json.NET for parsing the result
var mediaJson = JsonConvert.DeserializeObject(media);
//You can deserialize json result to one of the models in InstagramCSharp or to your custom model
//var mediaJson = JsonConvert.DeserializeObject<Envelope<Media>>(mediaJson);
return mediaJson;
}
}
you can try this
https://www.instagram.com/USERID/?__a=1
it is working with me :)
While running multiple test cases, selenium is entering invalid text as shown in the attachment.
Below are the two Examples showing the error:
Instead of entering AutomationTest123_6035633258972, it just enters 6035633258972. .
Instead of Entering AutomationTest123_636010703068635512, it just
enters utomationTest123_636010703068635512. .
Code
//StaticVariable is class which has static values
var username = StaticVariable.username;
var password = StaticVariable.password;
driver.FindElement(By.Id("username")).SendKeys(username); //putting wrong values
driver.FindElement(By.Id("password")).SendKeys(password); //putting wrong values
driver.FindElement(By.Id("login")).Click();
Can anyone help me on this? Any help would appreciated.
first of all make sure that
var username = StaticVariable.username;
is assigning the right value.
use a
print
to check what the value of username after assign.
than try by using the below code:
driver.FindElement(By.Id("username")).click()
driver.FindElement(By.Id("username")).clear()
driver.FindElement(By.Id("username")).SendKeys(username);
There can be a couple of reasons I've seen that this can be an issue. I'd first try to clear out the text input first and make sure it has focus.
var username = StaticVariable.username;
var password = StaticVariable.password;
// Fill out user name
var userElem = driver.findElement(By.id("username"));
userElem.click();
userElem.clear();
userElem.sendKeys(userName);
// Fill out password
var passElem = driver.findElement(By.id("password"));
passElem.click();
passElem.clear();
passElem.sendKeys(password);
// Click login button
driver.findElement(By.id("login"))
.click();
If, however, that doesn't fix it, I've had situations where splitting the string up and sending keys a few at a time has worked. That does have a performance penalty so I wouldn't do it unless you really really need to.
public void fooTest() {
// Do stuff to get to the correct page, etc
var username = StaticVariable.username;
var password = StaticVariable.password;
// Fill out user name
var userElem = driver.findElement(By.id("username"));
sendKeys(userElem, userName);
// Fill out password
var passElem = driver.findElement(By.id("password"));
sendKeys(passElem, password);
// Click login button
driver.findElement(By.id("login"))
.click();
// do assertions, etc
}
private void sendKeys(WebElement elem, String keys) {
elem.click();
elem.clear();
for (int i = 0; i < keys.length(); i) {
elem.sendKeys(keys.charAt(i));
}
}
Note : sorry for any syntax / c# errors, I've barely used the language ... I'm much more familiar with Java ;-)
Use the clear method then type the text: driver.findElement(By.cssSelector("").clear();
It may help.
Rather than using 'var' , you might want to try putting in the specific type , such as 'string'. The problem has to be in what is being passed to .SendKeys() or how it is being received by the function.
string username = StaticVariable.username;
string password = StaticVariable.password;
Hello to all programmers out there!
I am currently developing a module wherein I need to have a search for all users in my DNN portal. And I don't know what is the right way of doing so. I just have to populate a gridview with the users username and UserID with a field populated with a button. So overall. I need to have 3 fields wherein:
1st field = Username
2nd field = UserID
3rd Field = a Button(Which I already know how to include in a gridview)
I also have a textbox and a buttonSearch wherein in the textbox I will search for an existing username else, I shall throw an exception or message perhaps. So whenever there is a username existing prior to what I searched, the gridview will return with the information.
As of now I'm really puzzled here. And I only have this:
public static UserInfo GetUserByName(int portalId, string username)
{
}
And I'm not sure what to do next.
Any response would be really appreciated.
I updated my answer to reflect the function wrap that you originally suggested. I am using the GetUsersBasicSearch function of DotNetNuke.Entities.Users to look for a user by username. I'm not sure what you need a gridview for? If you are searching for a username, it will likely return just 1 user. Are you wanting to partially match the username and show multiple matches in a gridview?
public static UserInfo GetUserByName(int portalId, string username)
{
var foundUsers = UserController.Instance.GetUsersBasicSearch(portalId, 0, 10, "UserID", true, "UserName", username);
if (foundUsers.Any())
{
return foundUsers.FirstOrDefault();
}
else
{
return null;
}
}
When I execute the below code, the mail id is not added to the list, but the "result" parameter contains the value of Email,EUIdl, LEId. Anyone can give the exact code. The code taken from
https://github.com/danesparza/MailChimp.NET
MailChimpManager mc = new MailChimpManager("5323a23b12022d250c23c48253641dd5-us8");
// Create the email parameter
EmailParameter email = new EmailParameter()
{
Email = "riyas.k13#gmail.com"
};
EmailParameter results = mc.Subscribe("33cacee7d8", email);
With the MCAPI this is the call to subscribe to a list, you might want to check all the options in the subscribeOptions, and determine your required Merge values
MCApi mc = new MCApi(ConfigurationManager.AppSettings["MCAPIKey"], false);
var subscribeOptions = new Opt<List.SubscribeOptions>(new List.SubscribeOptions { SendWelcome = true, UpdateExisting = true });
var merges = new Opt<List.Merges>(new List.Merges { { "FNAME", [Subscriber FirstName here] }, { "LNAME", [Subscriber lastName here] } });
if (mc.ListSubscribe(ConfigurationManager.AppSettings["MCListId"], [Subscriber email ], merges, subscribeOptions))
// The user is subscribed Do Something
I had the same issue where the code seemed to work but no email was added to the list. The code does work by the way.
When a new email address is added to the mail list MailChimp sends out a confirmation email to that address, which you need need to confirm naturally.
If you don't do this the new email address won't be added to the list. If you didn't receive any email at the target address check the spam folder or see if any filters have accidentally caught it without you realising.
Sad to say I spent a good few hours going around in circles because of this.
This depends on maichimp list setting when you created the list. There is something called "ask users to confirm the subscription". By default, if admin checked this option, after importing, the users will receive confirmation emails. New added user names will be added only if they confirmed.
If you don't want to sent confirmation emails but directly added new users. Set "DoubleOptIn" to false.
/*
Set subscribe options
*/
MailChimp.Types.List.SubscribeOptions option = new MailChimp.Types.List.SubscribeOptions();
option.UpdateExisting = true;
option.DoubleOptIn = false;
List<MailChimp.Types.List.Merges> lstMerges = new List<MailChimp.Types.List.Merges>();
/*
Merge new users here.
*/
returnStatus = api.ListBatchSubscribe("your MailChimp List ID", lstMerges, option);
We are working on implementing some custom code on a workflow in a Sitecore 6.2 site. Our workflow currently looks something like the following:
Our goal is simple: email the submitter whether their content revision was approved or rejected in the "Awaiting Approval" step along with the comments that the reviewer made. To accomplish this we are adding an action under the "Approve" and "Reject" steps like so:
We are having two big issues in trying to write this code
There doesn't seem to be any easy way to determine which Command was chosen (the workaround would be to pass an argument in the action step but I'd much rather detect which was chosen)
I can't seem to get the comments within this workflow state (I can get them is the next state though)
For further context, here is the code that I have so far:
var contentItem = args.DataItem;
var contentDatabase = contentItem.Database;
var contentWorkflow = contentDatabase.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//contentWorkflow.GetCommands
var status = contentWorkflow.GetState(contentHistory[contentHistory.Length - 1].NewState);
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
//approve/reject comments
var message = contentHistory[contentHistory.Length - 1].Text;
//sitecore user (so we can get email address)
var submittingUser = sc.Security.Accounts.User.FromName(lastUser, false);
}
I ended up with the following code. I still see no good way to differentiate between commands but have instead implemented two separate classes (one for approve, one for reject):
public void Process(WorkflowPipelineArgs args)
{
//all variables get initialized
string contentPath = args.DataItem.Paths.ContentPath;
var contentItem = args.DataItem;
var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
var status = "Approved";
var subject = "Item approved in workflow: ";
var message = "The above item was approved in workflow.";
var comments = args.Comments;
//Get the workflow history so that we can email the last person in that chain.
if (contentHistory.Length > 0)
{
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
var submittingUser = Sitecore.Security.Accounts.User.FromName(lastUser, false);
//send email however you like (we use postmark, for example)
//submittingUser.Profile.Email
}
}
I have answered a very similar question.
Basically you need to get the Mail Workflow Action and then you need to further extend it to use the original's submitter's email.
Easiest way to get the command item itself is ProcessorItem.InnerItem.Parent
This will give you the GUID for commands like submit, reject etc.
args.CommandItem.ID
This will give you the GUID for states like Draft, approved etc.
args.CommandItem.ParentID