Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

[wip][eyes] add eyes cog #4

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

[wip][eyes] add eyes cog #4

wants to merge 14 commits into from

Conversation

Chovin
Copy link
Collaborator

@Chovin Chovin commented Apr 19, 2017

right now only works if loaded via repl
this is where the cog started

Desc:

  1. colored logs to console for easy moderation
  2. ping the console using the ANSI bell based on regex
  3. want to add relatively easy toggling n such
  4. need to clean up the class C stuff. rethink the way coloring is done
  5. what else you guys think?

Chovin added 2 commits April 20, 2017 02:15
only works if loaded via repl
this is where the cog started
sorry, not very github-flowy

still not in working condition.
lots of settings though:
[p]eyes channel  # log a channel
[p]eyes server  # act like toggling all channels
[p]eyes list  # list logged channels (should we have something about servers? maybe in PM)
[p]eyes timezone  # tries to get current tz by default, but lets you choose
[p]eyes bell  # settings for ANSI bell
[p]eyes bell toggle  # toggle whole server or individual channels (keep an eye out for this later)
[p]eyes bell user  # toggles watching for a username in server
[p]eyes bell me  # toggles watching bot owner everywhere
[p]eyes bell regex  # toggles specific regex. (add global regex later)
@Chovin
Copy link
Collaborator Author

Chovin commented Apr 19, 2017

please read the recent commit description

Copy link
Collaborator Author

@Chovin Chovin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some comments

eyes/eyes.py Outdated
EMPTY_REGEX_SETS = {"USERS": [], "RAW": []}


class C:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really need to rewrite this enum better



class Eyes:
"""👀"""
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the minimal descriptions on this cog. are you guys opposed?

def __init__(self, bot):
self.bot = bot
self.settings = dataIO.load_json(SETTINGS_PATH)
self.bot.loop.create_task(self.update_me_help())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kinda hacky. not sure if it works

eyes/eyes.py Outdated
bells = self.settings['BELLS']
return self.bell_id(channel_or_server) in bells"""

def bell_id(self, channel_or_server):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might trip you up. is there a cleaner simple way to do this?

eyes/eyes.py Outdated
def save(self):
return dataIO.save_json(SETTINGS_PATH, self.settings)

def highlight_me(self, content, server):
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to rethink the whole way we colorize things

chan_sets = self.settings['CHANNELS']
try: # lol
serv_sets.remove(server.id)
except ValueError:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new way to toggle \o/

eyes/eyes.py Outdated


# REGEX:
# "{@100406911567949824.display_name}".format(**{'@'+m.id: m for m in server.members})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this works.
gross for large servers but I kinda want to use it cause it works and it's new.
plus, that means we can do it easily for owner and other users

server = ctx.message.server
me = server.me
text_channels = [c for c in server.channels
if c.type is discord.ChannelType.text]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, don't check for read_permission here. should we do so when adding?
mmm naw.
but should we let the user know somehow if a channel is not readable?


msg = "I have :eyes:s in:\n"
if chans > len(text_channels) / 2:
msg = "I don't have :eyes:s in:\n"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to give the user the lesser of the 2

@Chovin
Copy link
Collaborator Author

Chovin commented Apr 20, 2017

if the bell is off for a server, should it still highlight bell regex matches blue?
image

pinned = "PINNED: " if m.pinned else "{}PINNED: ".format(C.BOLD+"UN"+C.ENDC+C.OKGREEN)

c = highlight_me(C.green(pad(m.clean_content)))
ms = dt.datetime.now().strftime('%H:%M%p')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use timestamp + TZ setting throughout

@Chovin
Copy link
Collaborator Author

Chovin commented Apr 20, 2017

should be able to use this for aware replacements of color
image

@Chovin
Copy link
Collaborator Author

Chovin commented Apr 20, 2017

should it be the person's display_name instead?
image
in the screenshot, you can't tell I'm pinging shigbeard
@{ir}meiguess(irdumb#1299): blah blah ?

@UltimatePancake
Copy link
Contributor

I feel like both names should be shown, actually.

c = self.highlight_bells(msg)
ms = dt.datetime.now().strftime('%H:%M%p') # use timestamp + TZ throughout
mcl = max_channel_length(msg)
ms += ' #{:<{}} @{}:{}'.format(msg.channel.name, mcl, msg.author, c)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@{ir}meiguess(irdumb#1299) instead

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants