Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] aviso con mensaje random para los dias feriados #51

Merged
merged 16 commits into from
Jun 17, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ class Bot extends Client {
next_class_embed = this.embeds.get(
'nextFaceToFaceClass'
) as EmbedPage;
} else if (event.summary.includes('Holiday')) {
ilitteri marked this conversation as resolved.
Show resolved Hide resolved
next_class_embed = this.embeds.get('holiday') as EmbedPage;
} else {
this.logger.error(`Invalid class type.`);
}
Expand Down
21 changes: 14 additions & 7 deletions src/components/embed_pages/FaceToFaceClassInfoEmbedPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,26 @@ export const data = new EmbedPage(
},
{
name: 'Temas a ver',
value: extractTopicsFromEventDescription(event.description),
value: event.summary.includes('Holiday')
ilitteri marked this conversation as resolved.
Show resolved Hide resolved
? 'NO HAY CLASES'
: extractTopicsFromEventDescription(event.description),
},
{
name: 'Ejercicio a tener entregado',
value: extractExercisesFromEventDescription(event.description),
value: event.summary.includes('Holiday')
? 'NO HAY CLASES'
: extractExercisesFromEventDescription(event.description),
},
{
name: 'Paper a tener leído',
value:
extractLecturesFromEventDescription(event.description) +
'\n*Para encontrar el link a un paper podés hacerlo desde ' +
client.channels.cache.get(client.config.papersTextChannelID)?.toString() +
' o en la [web de la cátedra](https://algoritmos-iii.github.io/)*',
value: event.summary.includes('Holiday')
? 'NO HAY CLASES'
: extractLecturesFromEventDescription(event.description) +
'\n*Para encontrar el link a un paper podés hacerlo desde ' +
client.channels.cache
.get(client.config.papersTextChannelID)
?.toString() +
' o en la [web de la cátedra](https://algoritmos-iii.github.io/)*',
},
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
],
null,
Expand Down
46 changes: 46 additions & 0 deletions src/components/embed_pages/HolidayEmbedPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { EmbedPage } from '../models/EmbedPage';
import { client } from '../../index';

export const data = new EmbedPage(
client,
false,
false,
false,
'holiday',
'Hoy no hay clase',
'',
[client.config.generalTextChannelID],
[
{
name: 'Frase insipradora del dia',
value: get_alan_kay_phrase(Math.floor(Math.random() * 15)),
josuebouchard marked this conversation as resolved.
Show resolved Hide resolved
},
],
null,
null,
client.guilds.cache
.first()!
.roles.cache.get(client.config.studentRoleID)
?.toString()
);

function get_alan_kay_phrase(random_number: number): string {
let alan_kay_quotes: string[] = [
'Most people have managed to get by without being educated…because, in order to make education more user-friendly, they managed to forget about the changes in people´s brains that are supposed to happen.',
'Television is the last technology we should be allowed to invent and put out without a surgeon general’s warning.',
'In natural science, Nature has given us a world and we’re just to discover its laws. In computers, we can stuff laws into it and create a world.',
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
'The future is not laid out on a track. It is something that we can decide, and to the extent that we do not violate any known laws of the universe, we can probably make it work the way that we want to.',
'The Internet was done so well that most people think of it as a natural resource like the Pacific Ocean, rather than something that was man-made. When was the last time a technology with a scale like that was so error-free? The Web, in comparison, is a joke. The Web was done by amateurs.',
'People who are really serious about software should make their own hardware.',
'Some people worry that artificial intelligence will make us feel inferior, but then, anybody in his right mind should have an inferiority complex every time he looks at a flower.',
"Normal is the greatest enemy with regard to creating the new. And the way of getting around this is you have to understand normal not as reality, but just a construct. And a way to do that, for example, is just travel to a lot of different countries and you'll find a thousand different ways of thinking the world is real, all of which are just stories inside of people's heads. That's what we are too. Normal is just a construct, and to the extent that you can see normal as a construct in yourself, you have freed yourself from the constraints of thinking this is the way the world is. Because it isn't. This is the way we are.",
"Scratch the surface in a typical boardroom and we're all just cavemen with briefcases, hungry for a wise person to tell us stories.",
"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it.",
'Simple things should be simple, complex things should be possible.',
"I don't know how many of you have ever met Dijkstra, but you probably know that arrogance in computer science is measured in nano-Dijkstras.",
'Technology is anything invented after you were born.',
'The most disastrous thing that you can ever learn is your first programming language.',
];

return alan_kay_quotes[random_number];
}
21 changes: 14 additions & 7 deletions src/components/embed_pages/VirtualClassInfoEmbedPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,26 @@ export const data = new EmbedPage(
},
{
name: 'Temas a ver',
value: extractTopicsFromEventDescription(event.description),
value: event.summary.includes('Holiday')
ilitteri marked this conversation as resolved.
Show resolved Hide resolved
? 'NO HAY CLASES'
: extractTopicsFromEventDescription(event.description),
},
{
name: 'Ejercicio a tener entregado',
value: extractExercisesFromEventDescription(event.description),
value: event.summary.includes('Holiday')
? 'NO HAY CLASES'
: extractExercisesFromEventDescription(event.description),
},
{
name: 'Paper a tener leído',
value:
extractLecturesFromEventDescription(event.description) +
'\n*Para encontrar el link a un paper podés hacerlo desde ' +
client.channels.cache.get(client.config.papersTextChannelID)?.toString() +
' o en la [web de la cátedra](https://algoritmos-iii.github.io/)*',
value: event.summary.includes('Holiday')
? 'NO HAY CLASES'
: extractLecturesFromEventDescription(event.description) +
'\n*Para encontrar el link a un paper podés hacerlo desde ' +
client.channels.cache
.get(client.config.papersTextChannelID)
?.toString() +
' o en la [web de la cátedra](https://algoritmos-iii.github.io/)*',
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
},
],
null,
Expand Down
23 changes: 18 additions & 5 deletions submodules/repositories/events_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,27 @@ def events(self):
return self.__service.service().events()

def next_event(self) -> Dict[str, Any]:
now = datetime.datetime.utcnow().isoformat() + 'Z'
print(f'Getting event from: {now.split()}')
request = self.events().list(calendarId=self.__calendar_id, timeMin=now,
# now = datetime.datetime.utcnow().isoformat() + 'Z'
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
now = datetime.datetime.utcnow()
next_class = now + datetime.timedelta(days = 4)
print(f'Getting event from: {now.isoformat().split()}')
request = self.events().list(calendarId=self.__calendar_id, timeMin=now.isoformat()+"Z", timeMax = next_class.isoformat()+"Z",
maxResults=1, singleEvents=True, orderBy='startTime')
IAvecilla marked this conversation as resolved.
Show resolved Hide resolved
response = request.execute()

if len(response.get('items', [])) == 0:
print('No upcoming events found. CHECK IF THE CALENDAR ID IS CORRECT')
return {}
print('No upcoming events found. Probably is holiday')
return {
"summary": "Holiday",
"eventDescription": "NO HAY CLASES",
"start": {
"dateTime": "",
"timeZone": ""
},
"end": {
"dateTime": "",
"timeZone": ""
},
}

return response.get('items', [])[0]