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

Printing colorful EventPrediction results - and more! #82

Merged
merged 13 commits into from
Feb 26, 2021
Merged

Printing colorful EventPrediction results - and more! #82

merged 13 commits into from
Feb 26, 2021

Conversation

TipicoDev
Copy link
Contributor

@TipicoDev TipicoDev commented Feb 19, 2021

Description

Added colorama to the requirements and made a simple code to print win results in green and lose results in red.

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been updated in requirements.txt

Added colorama to the requirements and made a simple code to print win results in green and lose results in red
@Tkd-Alex
Copy link
Owner

This PR will close #45


Moreover, I want to suggest some changes:

  • Create a boolean value inside LoggerSettings, so the use can choose if want/or not the colors.
  • Edit our EmojiFormatter and rename to GlobalFormatter, GeneralFormatter, Formatter or whatever name you think can be correct
    class EmojiFormatter(logging.Formatter):
    def __init__(self, *, fmt, datefmt=None, print_emoji=True):
    self.print_emoji = print_emoji
    logging.Formatter.__init__(self, fmt=fmt, datefmt=datefmt)
    def format(self, record):
    record.emoji_is_present = (
    record.emoji_is_present if hasattr(record, "emoji_is_present") else False
    )
    if (
    hasattr(record, "emoji")
    and self.print_emoji is True
    and record.emoji_is_present is False
    ):
    record.msg = emoji.emojize(
    f"{record.emoji} {record.msg.strip()}", use_aliases=True
    )
    record.emoji_is_present = True
    if self.print_emoji is False:
    if "\u2192" in record.msg:
    record.msg = record.msg.replace("\u2192", "-->")
    # With the update of Stream class It's possible that the Stream Title contains emoji
    # Full remove using a method from utils.
    record.msg = remove_emoji(record.msg)
    return super().format(record)
  • You can take some good code from here:
    https://github.com/GramAddict/bot/blob/e84fdee2c5f6991e9e9cd029b687f5ffac219877/GramAddict/core/log.py#L9-L29
    With these changes we are able to use the extra attribute (as we already do with emoji) and set the colors.
from colorama import Fore
logger.info("Text", extra={"color": f"{Fore.GREEN}"})

@TipicoDev
Copy link
Contributor Author

TipicoDev commented Feb 20, 2021

@Tkd-Alex tried my best since I'm not that good on python. Also updated the documentation, but feel free to edit it as you want :)
Please check if that works for you.

@Tkd-Alex
Copy link
Owner

I'll see tomorrow 😁😁

@Tkd-Alex Tkd-Alex linked an issue Feb 21, 2021 that may be closed by this pull request
@Tkd-Alex
Copy link
Owner

Sorry today I can't test 😞
I'll open a very fast review with 2 question.

Run also pre-commit for fix the code-checker.
https://github.com/Tkd-Alex/Twitch-Channel-Points-Miner-v2/blob/master/CONTRIBUTING.md#python-styleguide

TwitchChannelPointsMiner/TwitchChannelPointsMiner.py Outdated Show resolved Hide resolved
TwitchChannelPointsMiner/logger.py Outdated Show resolved Hide resolved
@Tkd-Alex
Copy link
Owner

For the rest: awesome work! And thanks for your time 🥳

…ileHandler. Add before the file logger and then console logger.
@Yishaqel
Copy link

For me it works perfectly, I would like to suggest a different color for when a bet starts (for example blue color). Thanks for your time in improving this!

@Tkd-Alex
Copy link
Owner

For me it works perfectly, I would like to suggest a different color for when a bet starts (for example blue color). Thanks for your time in improving this!

@Yishaqel For which message in particular?

  • Place the bet after...
  • Going to complete...
  • Place 2345 channel...
    All of this?

@TipicoDev do you want to do it? 😸

@Yishaqel
Copy link

For me it works perfectly, I would like to suggest a different color for when a bet starts (for example blue color). Thanks for your time in improving this!

@Yishaqel For which message in particular?

  • Place the bet after...
  • Going to complete...
  • Place 2345 channel...
    All of this?

@TipicoDev do you want to do it? 😸

In general, messages containing the bet. Anyway I have no problem if you think of doing it differently, it is just good to know who you are betting on.

@Signko
Copy link
Contributor

Signko commented Feb 22, 2021

22/02/21 23:22:31 - INFO - [__print_report]: Duration 1:19:38.750500
No issues have been found throughout the running of the script.
Works just perfectly.

@Signko
Copy link
Contributor

Signko commented Feb 23, 2021

23/02/21 06:50:48 - INFO - [__print_report]: Duration 7:26:40.923265
It still works, without any troubles. A perfect alternative for Windows users who cant use emojis when running this script.

Not gonna lie, would suggest adding more customization (Which colors should it use for bet win/lose)
And, maybe even color for a message with points being gained.

For example:
23/02/21 05:43:50 - INFO - [on_message]: +50 --> Streamer(username=nightbotuhc, channel_id=62713040, channel_points=15.31k) - Reason: CLAIM. (but in whatever color it's being choosed in the run.py file.)

@Tkd-Alex
Copy link
Owner

Tkd-Alex commented Feb 23, 2021

Guys for me It's a pleasure that participate actively on this project with PR / Issue and idea 💘
Personally I don't need the coloured terminal, but I see for most of you and especially for Windows user is a great feature!

We have already discussed here #45 how can be "difficult" to find a good colour palette. I've 3 ideas:

  1. Create a customizable theme
  2. Give the ability to create a custom theme / colour palette
  3. Make the colours static and If you don't like, It's not my problem 🤣

I want just to say if @TipicoDev have the time to work on It and If someone can help to find the "right colours" for each message. So we have a unique PR.
If this is not the case I'll merge this PR and I hope another user in the future will implement the other message's colour. Currently, I don't have too much time, but maybe, I can also work on this in the future 😸

@TipicoDev
Copy link
Contributor Author

Sorry for the delay. I've been kinda busy at work this days.
@Tkd-Alex I don't really have much time to work on it for now, I guess we can just merge this as a WIP and improve it whenever me or someone else have some time.
Thanks a lot for everyone's help! =)

@Tkd-Alex
Copy link
Owner

Tkd-Alex commented Feb 25, 2021

Someone can test my last commit? 🥳
Look at the README.md before the example.

from colorama import Fore
ColorPalette(
    "STREAMER_ONLINE" = Fore.GREEN,
    "STREAMER_OFFLINE" = Fore.RED,
    "GAIN_FOR_RAID" = Fore.YELLOW,
    "GAIN_FOR_CLAIM" = Fore.YELLOW,
    "GAIN_FOR_WATCH" = Fore.YELLOW,
    "BET_WIN" = Fore.GREEN,
    "BET_LOSE" = Fore.RED,
    "BET_REFUND" = Fore.RESET,
    "BET_FILTERS" = Fore.MAGENTA,
    "BET_GENERAL" = Fore.BLUE,
    "BET_FAILED" = Fore.RED,
)

@kelukelol @Yishaqel

@Tkd-Alex Tkd-Alex changed the title Printing colorful EventPrediction results Printing colorful EventPrediction results - and more! Feb 25, 2021
@Yishaqel
Copy link

This is working correctly but I recommend to add the possibility to add a color to:

26/02 11:09:01 - Place the bet after: 55.39s for: EventPrediction: Streamer (333.33k points) - Top 2

@Tkd-Alex
Copy link
Owner

This is working correctly but I recommend to add the possibility to add a color to:

26/02 11:09:01 - Place the bet after: 55.39s for: EventPrediction: Streamer (333.33k points) - Top 2

In BET_GENERAL or in separated key?

@Yishaqel
Copy link

This is working correctly but I recommend to add the possibility to add a color to:
26/02 11:09:01 - Place the bet after: 55.39s for: EventPrediction: Streamer (333.33k points) - Top 2

In BET_GENERAL or in separated key?

For me it would be better in a different key to recognize who is starting a bet

@Tkd-Alex Tkd-Alex merged commit b8f6fd0 into Tkd-Alex:master Feb 26, 2021
@Tkd-Alex Tkd-Alex added the enhancement New feature or request label Mar 9, 2021
1v pushed a commit to 1v/Twitch-Channel-Points-Miner-v2 that referenced this pull request Dec 20, 2022
…s/docker/setup-buildx-action-2.2.1

Bump docker/setup-buildx-action from 2.0.0 to 2.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command line colors for easy distinction
4 participants