Technological updates for the `Hangover` program
The proposed improvements are: - Update of the framework to .net6; - Update Twilio to the latest version; - Improve readability with clean code;
This commit is contained in:
parent
b14a0a89bd
commit
7b5429d05a
|
|
@ -1,34 +1,36 @@
|
|||
namespace Hacker_Scripts
|
||||
using Twilio;
|
||||
using Twilio.Rest.Api.V2010.Account;
|
||||
|
||||
//Exit early if any session with my username is found
|
||||
if (args[0] is null)
|
||||
{
|
||||
using System;
|
||||
using Twilio;
|
||||
using System.Linq;
|
||||
|
||||
class Hangover
|
||||
{
|
||||
public static string TWILIO_ACCOUNT_SID = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
|
||||
public static string AUTH_TOKEN = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
|
||||
|
||||
public static string YOUR_NUMBER = "9879789978";
|
||||
public static string BOSS_NUMBER = "3213213233";
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var twilio = new TwilioRestClient(TWILIO_ACCOUNT_SID, AUTH_TOKEN);
|
||||
|
||||
string[] randomMessages = {
|
||||
"Locked out",
|
||||
"Pipes broke",
|
||||
"Food poisoning",
|
||||
"Not feeling well"
|
||||
};
|
||||
|
||||
int randomIndex = new Random().Next(randomMessages.Count());
|
||||
String messageToSend = (randomMessages[randomIndex]);
|
||||
|
||||
var message = twilio.SendMessage(YOUR_NUMBER, BOSS_NUMBER, messageToSend);
|
||||
Console.WriteLine(message.Sid);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var twilioAccountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
|
||||
var authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");
|
||||
|
||||
//Phone numbers
|
||||
const string myNumber = "+xxx";
|
||||
const string numberOfBoss = "+xxx";
|
||||
|
||||
TwilioClient.Init(twilioAccountSid, authToken);
|
||||
|
||||
string[] excuses = {
|
||||
"Locked out",
|
||||
"Pipes broke",
|
||||
"Food poisoning",
|
||||
"Not feeling well"
|
||||
};
|
||||
|
||||
var rand = new Random().Next(excuses.Length);
|
||||
var message = $"Gonna work from home. {excuses[rand]}";
|
||||
|
||||
//Send a text message
|
||||
var response = MessageResource.Create(
|
||||
body: message,
|
||||
from: new Twilio.Types.PhoneNumber(myNumber),
|
||||
to: new Twilio.Types.PhoneNumber(numberOfBoss)
|
||||
);
|
||||
|
||||
Console.WriteLine(response.Sid);
|
||||
|
|
|
|||
Loading…
Reference in New Issue