[ENG/ITA] Megaptera-marina Now Tells You Some Random Info About the Unto&Bisunto Contest
La versione italiana si trova sotto quella inglese
The italian version is under the english one
Megaptera-marina Now Tells You Some Random Info About the Unto&Bisunto Contest
After adding a bit of variety to the comments left by @megaptera-marina, I thought I’d make them even less monotonous and repetitive by including extra pieces of information that the script randomly attaches to a comment, making it even harder to receive two identical comments in a short span of time.
Now, @megaptera-marina has 10 base comments, which notify the author that their post has been reblogged, and 5 bits of contest-related info, randomly inserted into the comment text.
These 5 bits of information each refer to a different contest statistic, and I hope to expand them over time; to start with, they include:
- the total number of HIVE distributed so far by the contest
- the total number of users who have participated in the contest
- the user who has won the most HIVE
- the second user who has won the most HIVE
- the third user who has won the most HIVE
Their functionality is handled by the following functions, which carry out the calculations and return strings ready to be embedded in a comment.
def total_prizes(reader: csv.DictReader) -> str:
total = 0
for row in reader:
total += float(row["amount"].split()[0])
return (
f"The **Unto&Bisunto** contest has distributed prizes "
f"for a total of {total:.3f} HIVE? Impressive!"
)
def all_winners(reader: csv.DictReader) -> list:
totals = defaultdict(float)
for row in reader:
to = row["to"]
totals[to] += float(row["amount"].split()[0])
winners = [{"to": to, "amount": round(amount, 3)} for to, amount in totals.items()]
return sorted(winners, key=lambda x: x["amount"], reverse=True)
def most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"The most rewarded user in the **Unto&Bisunto** contest is... @{winners[0]['to']}, "
f"with {winners[0]['amount']} HIVE won! Congratulations :)"
)
def second_most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"The second most rewarded user in the **Unto&Bisunto** contest is @{winners[1]['to']}, "
f"with {winners[1]['amount']} HIVE brought home! Well done :)"
)
def third_most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"The third top winner of the **Unto&Bisunto** contest is @{winners[2]['to']}, "
f"thanks to {winners[2]['amount']} HIVE won! A great result :)"
)
def participants(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"Since its inception, the **Unto&Bisunto** contest has seen participation from {len(winners)} users... "
f"and you're one of them!"
)
This update, which I hope makes receiving comments from @megaptera-marina a bit more fun, has already been active for a few days, with @coccodema being the first to receive a comment in the new format, and it seems to be working correctly... aside from a small typo I just spotted and fixed 😅
As you can see, in some cases the contest info might involve tagging a user — in this case @mad-runner — so I kindly ask anyone who gets tagged to let me know if they’d prefer not to be tagged in the future, so I can update the script and exclude that user.
On the other hand, if anyone has ideas for other information that would be fun to include in @megaptera-marina’s comments, feel free to share them in the comments below! Expanding the pool of info would definitely be a plus and would help make this small project more fun and — I hope — useful in supporting the Unto&Bisunto contest.
cover image made with Bing AI
to support the #OliodiBalena community, @balaenoptera is 3% beneficiary of this post
If you've read this far, thank you! If you want to leave an upvote, a reblog, a follow, a comment... well, any sign of life is really much appreciated!
Versione italiana
Italian version
Megaptera-marina Adesso Racconta Alcune Info Casuali sul Contest Unto&Bisunto
Dopo aver aggiunto un minimo di varietà ai commenti lasciati da @megaptera-marina, ho pensato di renderli ancora meno monotoni e ripetitivi con l'aggiunta di ulteriori informazioni che lo script associa ad un commento in maniera casuale, così da rendere ancora più difficile ricevere due commenti esattamente identici in un arco di tempo molto breve.
Adesso, infatti, @megaptera-marina ha 10 commenti base, in cui segnala all'autore di aver effettuato il reblog del suo post, e 5 informazioni sul contest, che vengono inserite in maniera completamente casuale nel testo del commento.
Queste 5 informazione riguardano altrettante statistiche del contest e nel tempo spero di poterle ampliare ulteriormente; per iniziare, queste riguardano:
- il numero di HIVE distribuiti in totale sino ad oggi dal contest
- il numero di utenti totali che hanno partecipato al contest
- l'utente che ha vinto più HIVE
- il secondo utente che ha vinto più HIVE
- il terzo utente che ha vinto più HIVE
Il loro funzionamento è disciplinato da queste funzioni, che si occupano di effettuare i vari calcoli e restituiscono delle stringhe di testo pronte per essere incorporate in un commento.
def total_prizes(reader: csv.DictReader) -> str:
total = 0
for row in reader:
total += float(row["amount"].split()[0])
return (
f"Il contest **Unto&Bisunto** ha distribuito premi "
f"per un totale di {total:.3f} HIVE? Impressionante!"
)
def all_winners(reader: csv.DictReader) -> list:
totals = defaultdict(float)
for row in reader:
to = row["to"]
totals[to] += float(row["amount"].split()[0])
winners = [{"to": to, "amount": round(amount, 3)} for to, amount in totals.items()]
return sorted(winners, key=lambda x: x["amount"], reverse=True)
def most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"L'utente più premiato del contest **Unto&Bisunto** è... @{winners[0]['to']}, "
f"con {winners[0]['amount']} HIVE vinti! Congratulazioni :)"
)
def second_most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"Il secondo utente più premiato del contest **Unto&Bisunto** è @{winners[1]['to']}, "
f"con {winners[1]['amount']} HIVE portati a casa! Complimenti :)"
)
def third_most_rewarded(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"Il terzo maggior vincitore del contest **Unto&Bisunto** è @{winners[2]['to']}, "
f"grazie a {winners[2]['amount']} HIVE vinti! Un grandissimo risultato :)"
)
def participants(reader: csv.DictReader) -> str:
winners = all_winners(reader)
return (
f"Dalla sua nascita il contest **Unto&Bisunto** ha visto la partecipazione di {len(winners)} utenti... "
f"e tu sei uno di loro!"
)
Questa novità, che spero contribuisca a rendere un po' più divertente ricevere i commenti di @megaptera-marina, è già attiva da qualche giorno, con @coccodema che ha ricevuto il primo commento nel suo nuovo format, e mi sembra star funzionando in maniera corretta... a parte un piccolo refuso che ho visto per l'appunto poco fa ed ho appena corretto 😅
Come potete vedere, in alcuni casi l'informazione sul contest può comportare anche il tag di un utente - in questo caso @mad-runner - per cui invito chiunque venga taggato a farmi sapere se non vuole che questo avvenga più per il futuro, così che io possa intervenire sullo script e rimuovere il tag per quella determinata persona.
Se a qualcuno, invece, venisse in mente qualche altra informazione che sarebbe carino vedere riportata nei commenti di @megaptera-marina, me lo faccia sapere nei commenti! Ampliare quanto più possibile il pool di informazioni sarebbe sicuramente un bene e contribuirebbe a rendere questo piccolo progetto sempre più divertente e, spero, utile per supportare il contest Unto&Bisunto.
immagine di cover creata con Bing AI
a supporto della community #OliodiBalena, il 3% delle ricompense di questo post va a @balaenoptera
Se sei arrivato a leggere fin qui, grazie! Se hai voglia di lasciare un upvote, un reblog, un follow, un commento... be', un qualsiasi segnale di vita, in realtà, è molto apprezzato!
Posted Using INLEO
https://x.com/jewellery_all/status/1948127022242476059