Skip to content

Commit

Permalink
Add "server_password" argument
Browse files Browse the repository at this point in the history
Closes #27
  • Loading branch information
luk3yx committed Dec 8, 2024
1 parent fa285a7 commit 1ba3fc6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@ Format partially copied from [Keep a Changelog](https://keepachangelog.com).
Notes:
- I strongly recommend you use the latest version of miniirc, there are major
bugfixes that are not listed here.
- This changelog may contain typographical errors, it is still a
work-in-progress.
- This changelog may contain errors.

## 1.10.0 - 2024-12-09

### Added

- `server_password` command to send passwords on joining

### Changed

- Tags now get sent if you use an empty string as a value.
- Messages with multiple spaces separating arguments are now ignored instead
of being parsed incorrectly.

## 1.9.1 - 2022-12-14

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you have previously used miniirc, you may want to read the
## Parameters

```py
irc = miniirc.IRC(ip, port, nick, channels=None, *, ssl=None, ident=None, realname=None, persist=True, debug=False, ns_identity=None, auto_connect=True, ircv3_caps=set(), quit_message='I grew sick and died.', ping_interval=60, ping_timeout=None, verify_ssl=True, executor=None)
irc = miniirc.IRC(ip, port, nick, channels=None, *, ssl=None, ident=None, realname=None, persist=True, debug=False, ns_identity=None, auto_connect=True, ircv3_caps=set(), quit_message='I grew sick and died.', ping_interval=60, ping_timeout=None, verify_ssl=True, server_password=None, executor=None)
```

*Note that everything before the \* is a positional argument.*
Expand Down Expand Up @@ -63,7 +63,8 @@ irc.wait_until_disconnected()
| `ping_interval` | If no packets are sent or received for this amount of seconds, miniirc will send a `PING`, and if no reply is sent, after the ping timeout, miniirc will attempt to reconnect. Set to `None` to disable. |
| `ping_timeout` | The ping timeout used alongside the above `ping_interval` option, if unspecified will default to `ping_interval`. |
| `verify_ssl` | Verifies TLS/SSL certificates. Disabling this is not recommended as it opens the IRC connection up to MiTM attacks. If you have trouble with certificate verification, try running `pip3 install certifi` first. |
| `executor` | An instance of `concurrent.futures.ThreadPoolExecutor` to use when running handlers. |
| `server_password` | Sends the password with `PASS` command immediately after connection. If you are looking to log into a NickServ account, you probably want to use `ns_identity` instead. |
| `executor` | An instance of `concurrent.futures.ThreadPoolExecutor` to use when running handlers. *New in v1.10.0.* |

*The only mandatory parameters are `ip`, `port`, and `nick`.*

Expand Down
13 changes: 8 additions & 5 deletions miniirc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import atexit, threading, time, select, socket, ssl, sys, warnings

# The version string and tuple
ver = __version_info__ = (1, 9, 1)
version = 'miniirc IRC framework v1.9.1'
__version__ = '1.9.1'
ver = __version_info__ = (1, 10, 0)
version = 'miniirc IRC framework v1.10.0'
__version__ = '1.10.0'

# __all__ and _default_caps
__all__ = ['CmdHandler', 'Handler', 'IRC']
Expand Down Expand Up @@ -228,7 +228,8 @@ def __init__(self, ip, port, nick, channels=None, *, ssl=None, ident=None,
realname=None, persist=True, debug=False, ns_identity=None,
auto_connect=True, ircv3_caps=None, connect_modes=None,
quit_message='I grew sick and died.', ping_interval=60,
ping_timeout=None, verify_ssl=True, executor=None):
ping_timeout=None, verify_ssl=True, server_password=None,
executor=None):
# Set basic variables
self.ip = ip
self.port = int(port)
Expand All @@ -248,6 +249,7 @@ def __init__(self, ip, port, nick, channels=None, *, ssl=None, ident=None,
self.ping_interval = ping_interval
self.ping_timeout = ping_timeout
self.verify_ssl = verify_ssl
self.server_password = server_password
self._keepnick_active = False
self._executor = executor

Expand Down Expand Up @@ -414,9 +416,10 @@ def connect(self):
ctx.verify_mode = ssl.CERT_NONE
self.sock = ctx.wrap_socket(self.sock, server_hostname=self.ip)

# Begin IRCv3 CAP negotiation.
self._current_nick = self._desired_nick
self._unhandled_caps = None
if self.server_password is not None:
self.send('PASS', self.server_password, force=True)
self.quote('CAP LS 302', force=True)
self.quote('USER', self.ident, '0', '*', ':' + self.realname,
force=True)
Expand Down
2 changes: 1 addition & 1 deletion miniirc.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ class IRC:
auto_connect: bool = True, ircv3_caps: Optional[set[str]] = None,
connect_modes: Optional[str] = None,
quit_message: str = 'I grew sick and died.', ping_interval: int = 60,
verify_ssl: bool = True,
verify_ssl: bool = True, server_password: Optional[str] = None,
executor: Optional[concurrent.futures.ThreadPoolExecutor]
) -> None: ...
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='miniirc',
version='1.9.1',
version='1.10.0',
py_modules=['miniirc'],
author='luk3yx',
description='A lightweight IRC framework.',
Expand Down

0 comments on commit 1ba3fc6

Please sign in to comment.