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

[WIP] refactor, new features and bugfixes #387

Closed
wants to merge 34 commits into from

Conversation

rbignon
Copy link
Contributor

@rbignon rbignon commented Jan 9, 2023

New features:

  • display more information at connection
Welcome to the Slack Server Teamname, romain!
Your host is domain.slack.com, running version localslackirc-2.0
There are 125 users and 30 bots on 1 server
5 Slack Workspace Admins
105 channels formed
  • rename user's nickname at connection if not using the right one
You're now known as romain
  • use the slack domain (*.slack.com) instead of gethostname for server name and user hostnames
  • more information in WHOIS:
romain [U03D36HJC14@domain.slack.com]
 ircname  : Romain Bignon
          : Developer
 account  : romain@example.org
 account  : +33123456789
 account  : https://avatars.slack-edge.com/2022-10-27/XXXX_original.png
 channels : #general #random
 server   : domain.slack.com [TeamName]
 away     : My Status
          : Workspace Owner
 idle     : 0 days 23 hours 39 mins 19 secs
End of WHOIS
  • if I send a message to a user who is away, I get a RPL_AWAY message
  • add --thread-replies parameter to display thread answers in IM/channels instead of creating a new channel
  • handle threads in IM
  • correctly handle edited/deleted messages in IM
  • fix /me messages
  • USERHOST displays away/admin flags
  • handle CAP command (currently empty)
  • handle JOIN : command sent by recent irssi versions during connection (I don't know why, but if it doesn't get the right answer it freezes)
  • fix crash in some case during shutdown or user disconnection
  • handle slack connection errors
  • handle MODE with parameters to display an error
  • handle MODE +b to display an emply banlist
  • add command WHOWAS
  • concatenate multilines topic
  • use colored logs
  • handle groups and MPIM join/parts

Internal changes:

  • move *.py files into a new localslackirc module (requires to use python -m localslackirc to run it locally, it will need to change packaging to create a localslackirc script)
  • split irc.py into daemon.py and irc.py
  • do not use bytes anymore
  • rework of the commands handling
  • use logging module instead of syslog
  • do not crash if an exception is uncatched in a command handler, just display an error to user and display the backtrace in logs
  • flake8 fixes

@rbignon rbignon changed the title Wip refactor [WIP] refactor, new features and bugfixes Jan 9, 2023
@rbignon
Copy link
Contributor Author

rbignon commented Jan 9, 2023

I split into several commits:

  • create localslackirc python module and move python files into does not change anything
  • lot of changes is a commit with things not yet split
  • move methods inside the Server class is only method moves, no code changes

@ltworf
Copy link
Owner

ltworf commented Jan 9, 2023

Hello,

it's too big of a change to be done in a single PR.

  • As it is, tests are failing
  • There are regressions (logging to journald? deb package?)
  • There are changes that I can't understand why they are done and commit message offers no explaination.

I'm not opposed to merging big refactors, but they must be complete and not break anything.

Please make different changes into different branches so that I can respond and evaluate them.

@ltworf
Copy link
Owner

ltworf commented Jan 9, 2023

Basically every point should probably be a separate pull request, of one or many commits, depending how big or deep the change is.

At the very least existing tests should be passing.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 9, 2023

Hello,

it's too big of a change to be done in a single PR.

  • As it is, tests are failing
  • There are regressions (logging to journald? deb package?)
  • There are changes that I can't understand why they are done and commit message offers no explaination.

I'm not opposed to merging big refactors, but they must be complete and not break anything.

Please make different changes into different branches so that I can respond and evaluate them.

As said, the commit 'lot of changes' is not yet split. Also I've not yet fix packaging and tests (for packaging it would be nice if you could help me), that's a draft.

It's standard to log with the logging python package, it writes on stderr, journald reads stderr.

@ltworf
Copy link
Owner

ltworf commented Jan 10, 2023

It's standard to log with the logging python package, it writes on stderr, journald reads stderr.

I know how it works. But it also discards log level information, which gets lost forever. The log module has a syslog driver that needs to be used in order to preserve this information.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 10, 2023

It's standard to log with the logging python package, it writes on stderr, journald reads stderr.

I know how it works. But it also discards log level information, which gets lost forever. The log module has a syslog driver that needs to be used in order to preserve this information.

try:
    from systemd.journal import JournalHandler
except ImportError:
    pass
else:
    logging.root.addHandler(JournalHandler())

Something like that would be ok? I guess if you want to let people configure their log handlers, you should let them give a logging.yml config file, there is no reason to support syslog only.

@ltworf
Copy link
Owner

ltworf commented Jan 10, 2023

That's an external dependency… could be done but I'm not too happy about those.

Anyway I'm ok with extra configuration… logging.yml makes no sense because it's not how the rest is configured. Default behaviour has to remain unchanged if possible.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 10, 2023

I don't understand why using syslog instead of journald for an application. But if you want I can add an extra parameter --syslog/SYSLOG to add the syslog handler.

It crashed if a user deletes a message in a thread where the first
message was already deleted
Also, handle user_change in the common way instead of a custom
condition.

'message.message_replied' was not handled, as it's a subtype of
'message', we can't ignore it, so handle as a dataclass but ignore it.
@ltworf
Copy link
Owner

ltworf commented Jan 11, 2023

journald is only present with systemd. syslog is way more widespread.

If we don't use any specific journald features, there is no reason to require an external dependency.

I'd like the behaviour to remain the same: always log to syslog, and log to terminal if it's running in a terminal. No extra option should be required just to switch to the logging module

Ignore these errors:
- E501 line too long
- W504 line break after binary operator
@rbignon
Copy link
Contributor Author

rbignon commented Jan 22, 2023

I fixed tests, maybe you can help me to change packaging?

@ltworf
Copy link
Owner

ltworf commented Jan 22, 2023

Hello, thanks for this.

I'm going to have to ask you to split this into multiple pull requests, "title and phone in profiles" should not be in the same as "coloured logs".

After that I can review/merge/reject on the changes.

@ltworf
Copy link
Owner

ltworf commented Jan 22, 2023

If it's easier for you you can just post the pull requests one by one, if the later commits are already based on the previous ones.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 22, 2023

Ok, but it'll be complicated if you require to edit a commit or to reject ones.

@ltworf
Copy link
Owner

ltworf commented Jan 22, 2023

I can either reject the whole thing or review and decide case by case though… as it is, there could be anything in there.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 22, 2023

Done.

@rbignon
Copy link
Contributor Author

rbignon commented Jan 22, 2023

Maybe, before reviewing separate PR or commit, pull all commits and read the whole code.

@ltworf ltworf closed this Jan 22, 2023
@rbignon
Copy link
Contributor Author

rbignon commented Jan 22, 2023

Ok I don't care to be merged into your repository, I maintain my own fork.

Bye.

@ltworf
Copy link
Owner

ltworf commented Jan 22, 2023

Maybe, before reviewing separate PR or commit, pull all commits and read the whole code.

As it is, the whole code, can't be merged and has several issues.

Since you put everything into one single branch, the issues are too many to even list all of them.

Having separate independent branches would have made it possible to comment on the issues.

Ok I don't care to be merged into your repository, I maintain my own fork.

Ok. No problem.

@rbignon rbignon deleted the wip-refactor branch January 29, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants