Skip to content

Commit d2d863d

Browse files
Technological updates for the SmackMyBitch program
The proposed improvements are: - Update of the framework to .net6; - Update Twilio to the latest version; - Improve readability with clean code;
1 parent 7b5429d commit d2d863d

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

CSharp/SmackMyBitch.cs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
61
using Twilio;
2+
using Twilio.Rest.Api.V2010.Account;
73

8-
namespace Hacker_Scripts
4+
//Exit early if any session with my username is found
5+
if (args[0] is null)
96
{
10-
class SmackMyBitch
11-
{
12-
public static string TWILIO_ACCOUNT_SID = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
13-
public static string AUTH_TOKEN = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
14-
15-
public static string YOUR_NUMBER = "9879789978";
16-
public static string HER_NUMBER = "3213213233";
17-
18-
static void Main(string[] args)
19-
{
20-
var twilio = new TwilioRestClient(TWILIO_ACCOUNT_SID, AUTH_TOKEN);
21-
22-
string[] randomMessages = {
23-
"Working hard",
24-
"Gotta ship this feature",
25-
"Someone fucked the system again"
26-
};
27-
28-
int randomIndex = new Random().Next(randomMessages.Count());
29-
String messageToSend = (randomMessages[randomIndex]);
30-
31-
var message = twilio.SendMessage(YOUR_NUMBER, HER_NUMBER, messageToSend);
32-
Console.WriteLine(message.Sid);
33-
}
34-
}
7+
return;
358
}
9+
10+
var twilioAccountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
11+
var authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
12+
13+
//Phone numbers
14+
const string myNumber = "+xxx";
15+
const string herNumber = "+xxx";
16+
17+
TwilioClient.Init(twilioAccountSid, authToken);
18+
19+
string[] reasons = {
20+
"Working hard",
21+
"Gotta ship this feature",
22+
"Someone fucked the system again"
23+
};
24+
25+
var randomNumber = new Random().Next(reasons.Length);
26+
var reason = reasons[randomNumber];
27+
var message = $"Late at work. {reason}";
28+
29+
//Send a text message
30+
MessageResource.Create(
31+
body: message,
32+
from: new Twilio.Types.PhoneNumber(myNumber),
33+
to: new Twilio.Types.PhoneNumber(herNumber)
34+
);
35+
36+
//Log this
37+
Console.WriteLine($@"Message sent at: #{DateTime.Now} | Reason: #{reason}");

0 commit comments

Comments
 (0)