mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 19:13:54 +00:00
Better message for popular tweets
This commit is contained in:
parent
4f74a2e01a
commit
725140c6de
3 changed files with 8 additions and 3 deletions
|
|
@ -121,8 +121,12 @@ export default class DiscordEventHandler {
|
|||
}
|
||||
case "POPULAR_TWEET": {
|
||||
const dest = await this.getChannel(Config.POPULAR_TWEETS_CHANNEL_ID);
|
||||
const diff = (Date.now() - Number(action.date));
|
||||
const seconds = diff / 1000;
|
||||
const minutes = seconds / 60;
|
||||
const hours = Math.round(minutes / 60);
|
||||
|
||||
const message = `An @winampskins tweet just passed **${action.bracket}** likes!\n\n${action.url}`;
|
||||
const message = `⭐️ This tweet passed **${action.bracket}** likes! (**${action.likes}** likes in **${hours}** hours)️ ⭐\n\n${action.url}`;
|
||||
|
||||
await dest.send(message);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export type ApiAction =
|
|||
| { type: "GOT_FEEDBACK"; message: string; email?: string; url?: string }
|
||||
| { type: "SYNCED_TO_ARCHIVE"; successes: number; errors: number }
|
||||
| { type: "STARTED_SYNC_TO_ARCHIVE"; count: number }
|
||||
| { type: "POPULAR_TWEET"; bracket: number; url: string };
|
||||
| { type: "POPULAR_TWEET"; bracket: number; url: string, likes: number, date: Date };
|
||||
|
||||
export type EventHandler = (event: ApiAction) => void;
|
||||
export type Logger = {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import DiscordEventHandler from "../api/DiscordEventHandler";
|
|||
const MAX_CALL_COUNT = 2;
|
||||
|
||||
type TweetPayload = {
|
||||
created_at: string,
|
||||
entities: {
|
||||
urls: {
|
||||
expanded_url: string;
|
||||
|
|
@ -69,7 +70,7 @@ export async function popularTweets(handler: DiscordEventHandler) {
|
|||
const url = tweetUrl(tweet);
|
||||
|
||||
if(!notified) {
|
||||
await handler.handle({ type: "POPULAR_TWEET", url, bracket });
|
||||
await handler.handle({ type: "POPULAR_TWEET", url, bracket, likes: tweet.favorite_count, date: new Date(Date.parse(tweet.created_at))});
|
||||
notified = true
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue