I'm creating a discord bot which rewards users for the amount of invites they have.
The API allows you to retrieve the invitecount of an user when they do !invites for example however this can be easily botted so I'm trying to find a way to prevent botters.
Current code :
[Command("test")]
public async Task InviteCheck()
{
var test = await Context.Guild.GetInvitesAsync();
foreach (var tests in test)
{
if (Context.User.Username + "#" + Context.User.Discriminator == tests.Inviter.ToString())
{
//amount of invites
await Context.Channel.SendMessageAsync(tests.Uses.ToString());
}
}
}
So I got this idea to check when an user joins and then check their invite link, but apparently this is not included in the API.
In the documentation : https://discord.foxbot.me/docs/api/Discord.IInviteMetadata.html
it shows that I can retrieve the inviter information (I'm not certain) but I have no clue on how to use Iinvitemetadata.
Tldr; I want to make a discord bot which checks howmany valid invitations an user has, delete the invitation if the invited user leaves. User must be in group for 10 minutes before counting as an invitation.
You can check for an event when a new user joins the guild. See here
But i think Stackoverflow is not the right place for that kind of question since it is very vague and you won't get full out of the box solutions from users.
In your place i would grab the source code from their github repository and make my way through what it can do and how.
Alternativly you should ask this kind of question in the official unofficial "Discord API" Discord-Server where there is an extra channel for your library Discord.Net called "#dotnet_discord-net" - Here you go.
Im creating a tracking system in aspx c# and I want the user to submit a ticket and it'll assign it an ID and send the email.
I got everything to work but the problem is if two or more users are on the same page it'll assign them the same ID when they send the email (#150 and #150). However in Sql, it would be (#150 and #151).
aspx.cs page (Im getting the current ID from SQL)
id.Text = ds.Tables[0].Rows[0]["id"].ToString();
Then I'm incrementing it by 1 (to send the email) Because I dont want the current users that's sending the request to have an old ID.
id = id + 1;
Note that this works perfectly if only one users is on the page submitting the request.
Can someone get a work around this? Thanks!
In case you are using the logged-in user's id on the url to handle a user's session and also set the email ID (check example below):
.aspx?user_id=150&email_id=150
Then you need to use the appropriate user's session that opens your webpage as shown below to get the appropriate ID as an email ID.
id.Text = Session[user_id].ToString();
For that reason when both users are logged in simultaneously you only get the same id for both. You probably have a static site that handles only one session per user.
I have c# mvc web application.There is simple login page according to email and password. Now I have a need like that:
When a user login to the system, all active sessions that same email address will logout.
How can I achieve this?
You can use Session.Abandon() or Clear() to abandon the current session, but if there are multiple people logged in with the same address, this will not address that.
You'd have to build that detection in; for instance, you could update a flag on the table that represents your users and then in the other user's sessions periodically check the table if they were re-logged in. OR when a user logs in, create a token in a database table with an expiration date; associate that token to a user in a cookie. When logged out or logging back in, you could invalidate the token associated to that email address, and each user, when they attempt to access the application, could be rejected by your application checking whether the token is expired.
The Abandon method should work (MSDN):
Session.Abandon();
If you want to remove a specific item from the session use (MSDN):
Session.Remove("YourItem");
If you just want to clear a value you can do:
Session["YourItem"] = null;
If you want to clear all keys do:
Session.Clear();
If none of these are working for you then something fishy is going on. I would check to see where you are assigning the value and verify that it is not getting reassigned after you clear the value.
Simple check do:
Session["YourKey"] = "Test"; // creates the key
Session.Remove("YourKey"); // removes the key
bool gone = (Session["YourKey"] == null); // tests that the remove worked
I’m trying to create an event in my Microsoft Outlook calendar by using iCalendar standard. I’ve sent an email with content type “text/calendar” to my Exchange mailbox from .NET application.
It arrives to Outlook as an meeting request. Everything looks good, till the moment when I click the received meeting request, Outlook displays it as an empty calendar view with the text: “Meeting cannot be found in the calendar”.
I don’t understand why – I wanted to create an event and it is trying to find some existing?
If I send exactly the same email to whoever participant of the meeting except the organizer, it creates an event in their calendars and everything seems to be ok.
I’ve found that it is caused by the “ORGANIZER” property. If it is set to organizer’s email (my email) and I send meeting request to myself, an event is not created with the information “Meeting cannot be found in the calendar”.
So the question is why it doesn’t create an event for organizer? Organizer must have that event created to be notified by other participants if they have accepted or cancelled the meeting.
Here is the iCalendar:
BEGIN:VCALENDAR
PRODID:-//Company//Product 3.0//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VEVENT
DTSTART:20130225T200000Z
DTEND:20130225T203000Z
DTSTAMP:20130225T143039Z
ORGANIZER;CN="John Doe":mailto:john.doe#domain.com
UID:20130225T143039Z#domain.com
ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSVP=TRUE;CN="John Smith"
;X-NUM-GUESTS=0:mailto:john.smith#domain.com
CLASS:PUBLIC
CREATED:20130225T143039Z
DESCRIPTION:
LAST-MODIFIED:20130225T143039Z
LOCATION:
SEQUENCE:0
STATUS:CONFIRMED
SUMMARY:Booking test
TRANSP:OPAQUE
END:VEVENT
END:VCALENDAR
Let’s say that organizer want to create an meeting for 2 attendees. He fills in a form in the booking system.
The booking system sends email containing iCalendar standard to himself and to 2 meeting attendees.
This scenario doesn’t work.
It is not possible to create an event (cancellable meeting object) in the calendar of the organizer. The client thinks that email containing iCalendar format is just notification for attendee of the meeting already created in the organizer calendar. If such an email arrives to organizer’s mailbox, client app doesn’t create an event in the organizer’s calendar. It assumes that an event was created by organizer himself. E.g.: Outlook tells you in that case that “Meeting cannot be found in the calendar”.
If you ask Microsoft support about it, they only tell you that they does not support open standards: http://support.microsoft.com/kb/2269506
Working solution to this problem is to use platform services (Exchange Web Services or Google Calendar API) to create an event in the organizer’s calendar. Forget iCalendar standard.
The services can be configured for sending notifications to attendees automatically.
So it is enough to pass “SendInvitationsMode.SendToAllAndSaveCopy” if you’re using EWS:
Appointment appointment = new Appointment(service);
appointment.Subject = "Status Meeting";
appointment.Body = "The purpose of this meeting is to discuss status.";
appointment.Start = new DateTime(2014, 3, 1, 9, 0, 0);
appointment.End = appointment.Start.AddHours(2);
appointment.Location = "Conf Room";
appointment.RequiredAttendees.Add("user1#contoso.com");
appointment.RequiredAttendees.Add("user2#contoso.com");
appointment.OptionalAttendees.Add("user3#contoso.com");
appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
or set “sendNotifications” parameter to true in case of Google Calendar API.
You don’t need to send an email to every particular attendee.
This is a bit of an old issue, but i think it is caused from using
METHOD:REQUEST
This marks that the ical should be updated, not that it is a new item. Instead, use
METHOD:PUBLISH
I can confirm that this works with DDay.iCal and Outlook Calendars.
This drove me mad for a week, so it is nice to see someone else confirming what I suspected. There is actually a relatively simple solution, which solves the question, although it is not very elegant. I can understand why one would not be allowed to take the role of Organiser from an outside source, but it is annoying that you can't.
Send out 2 invites. One to yourself (or whoever the organiser is) and then a different one to everyone else.
The one to yourself should have something else other than you down as the ORGANSISER, e.g. ORGANIZER:donotreply#outlook.com
The one to everyone else should have your email down as the organizer.
For this approach to work, you should set METHOD:REQUEST. If you set it to PUBLISH you will get duplicates on updates.
This approach means you get the meeting in your diary and you also get replies (to get replies you need to include the following line for each attendee:
ATTENDEE;CN="The Name";RSVP=TRUE:mailto:the_email#address.com.)
Note that the UID is the same for both versions of the file. It helps if the ORGANISER gets the Invite first so they can accept it before they start getting replies, otherwise people will be replying to something that effectively does not yet exist. That wont stop them accepting the invite, but it might be a little confusing for the ORGANIZER. To help with this I put in a slight delay between email 1 and 2.
I would assume that your problem is because Exchange assumes that the organizer of the event is also the originator of the event. Which seems fair enough, as otherwise it would be child's play to send meetings to people making them the organizer and they would be added automatically to the person's calendar.
All that said, no idea how to get around the issue.
the behavior of event invitation being sent by email is described in rfc6047 which further extends the icalendar RFC (RFC5545).
section 2 and section 3 on security, summarizes two spoofing threats:
spoofing the "Organizer", and spoofing an "Attendee"
that is
spoof#xyz.example.net is not allowed to modify or cancel a meeting that was organized by a#example.com.
to your case:
did you send the invitation from the same email address as your exchange (talking about the From: in the mail not the Organizer:mailto ? if not it might be worth trying to send it via the exchange address.
should above not work, to address your need for the organizer to have the invitation in its calendar you probably will need to add it programmatically in the organizer's agenda as it is likely that the CUA (Calendar User Agent) or Exchange does not allow a 3rd party mailer to add events in agenda without end-user UI usage.
In recent months ,our service also meet the same problem as you:
our service create meeting calendar for organizer and attendees,
if attendees contains organizer ,organizer (as a atteendee) can get a calendar email,
but it does neither be allowed to receive/reject the meeting(the button is disabled) nor see it in calendar(no calendar event).
finally, I notice that only when under following condition this will happen:
1. mail.From = organizer
2. Ateendees.contains(organizer) //case-insensitive.
So , I simply change my code to follwing , and it works fine for all attendees (include organizer):
if (!attendeeEmail.ToLower().Contains(organizer.Address.ToLower()))
{
message.From = organizer;
}
else
{
//such as your actual email sender, in our case, our mail sender use another email,
//say ActualSender,and if leave empty, then our mail sender will fill as:
message.From = ActualSenderEmail;
}
The flow is:
user enters email address
after submit, an email is sent to the user
The email will include a link that will take the user to a reset password page.
Now, how do I fetch user's ID based on the email address and encrypt it? Then what should link be? Like, what I want is fetch the User ID then encrypt it somehow so that the link doesn't contain the actual ID and that link will take the user to a page that will have textboxes to reset the password. I am just confused how to go about it.
Also is this the secure way? To reset a password like this?
I usually create a new table in the database:
PasswordresetRequest with the following fields:
Id: Guid - Id of password reset request.
Accountid: string - username of user
Created: DataTime - timestamp of when password reset were created
Flow is as follows:
User request password reset at web site.
A new record is created in the PasswordresetRequest table.
An email with a link to the password reset page with the password request id as request parameter is sent to the user.
User click on link in email which send him to password reset page.
Password request if fetched from database from request parameter. If request could be found or and request is not older than e.g. 12 hours a form is presented to user where he can enter a new password.
This is pretty simple to implement and is secure enough for most sites.
There is any number of ways to go about doing this. If your major concern is security, one way could be to send a link that contains a guid parameter which you create and store on your end (in a db table, file or whatever suits you) together with the user id associated with it. When the request for password reset comes in, you check for the guid and look if there is one matching value in your db/file/whatever and proceed with the password reset. Don't forget to delete the guid from your storage to prevent multiple use of the same link.
There is a railscast on exactly this subject: http://railscasts.com/episodes/274-remember-me-reset-password?view=asciicast