Skip to content

Commit 1ba3fc6

Browse files
committed
Add "server_password" argument
Closes #27
1 parent fa285a7 commit 1ba3fc6

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,19 @@ Format partially copied from [Keep a Changelog](https://keepachangelog.com).
55
Notes:
66
- I strongly recommend you use the latest version of miniirc, there are major
77
bugfixes that are not listed here.
8-
- This changelog may contain typographical errors, it is still a
9-
work-in-progress.
8+
- This changelog may contain errors.
9+
10+
## 1.10.0 - 2024-12-09
11+
12+
### Added
13+
14+
- `server_password` command to send passwords on joining
15+
16+
### Changed
17+
18+
- Tags now get sent if you use an empty string as a value.
19+
- Messages with multiple spaces separating arguments are now ignored instead
20+
of being parsed incorrectly.
1021

1122
## 1.9.1 - 2022-12-14
1223

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ If you have previously used miniirc, you may want to read the
1919
## Parameters
2020

2121
```py
22-
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)
22+
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)
2323
```
2424

2525
*Note that everything before the \* is a positional argument.*
@@ -63,7 +63,8 @@ irc.wait_until_disconnected()
6363
| `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. |
6464
| `ping_timeout` | The ping timeout used alongside the above `ping_interval` option, if unspecified will default to `ping_interval`. |
6565
| `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. |
66-
| `executor` | An instance of `concurrent.futures.ThreadPoolExecutor` to use when running handlers. |
66+
| `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. |
67+
| `executor` | An instance of `concurrent.futures.ThreadPoolExecutor` to use when running handlers. *New in v1.10.0.* |
6768

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

miniirc.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import atexit, threading, time, select, socket, ssl, sys, warnings
99

1010
# The version string and tuple
11-
ver = __version_info__ = (1, 9, 1)
12-
version = 'miniirc IRC framework v1.9.1'
13-
__version__ = '1.9.1'
11+
ver = __version_info__ = (1, 10, 0)
12+
version = 'miniirc IRC framework v1.10.0'
13+
__version__ = '1.10.0'
1414

1515
# __all__ and _default_caps
1616
__all__ = ['CmdHandler', 'Handler', 'IRC']
@@ -228,7 +228,8 @@ def __init__(self, ip, port, nick, channels=None, *, ssl=None, ident=None,
228228
realname=None, persist=True, debug=False, ns_identity=None,
229229
auto_connect=True, ircv3_caps=None, connect_modes=None,
230230
quit_message='I grew sick and died.', ping_interval=60,
231-
ping_timeout=None, verify_ssl=True, executor=None):
231+
ping_timeout=None, verify_ssl=True, server_password=None,
232+
executor=None):
232233
# Set basic variables
233234
self.ip = ip
234235
self.port = int(port)
@@ -248,6 +249,7 @@ def __init__(self, ip, port, nick, channels=None, *, ssl=None, ident=None,
248249
self.ping_interval = ping_interval
249250
self.ping_timeout = ping_timeout
250251
self.verify_ssl = verify_ssl
252+
self.server_password = server_password
251253
self._keepnick_active = False
252254
self._executor = executor
253255

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

417-
# Begin IRCv3 CAP negotiation.
418419
self._current_nick = self._desired_nick
419420
self._unhandled_caps = None
421+
if self.server_password is not None:
422+
self.send('PASS', self.server_password, force=True)
420423
self.quote('CAP LS 302', force=True)
421424
self.quote('USER', self.ident, '0', '*', ':' + self.realname,
422425
force=True)

miniirc.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,6 @@ class IRC:
204204
auto_connect: bool = True, ircv3_caps: Optional[set[str]] = None,
205205
connect_modes: Optional[str] = None,
206206
quit_message: str = 'I grew sick and died.', ping_interval: int = 60,
207-
verify_ssl: bool = True,
207+
verify_ssl: bool = True, server_password: Optional[str] = None,
208208
executor: Optional[concurrent.futures.ThreadPoolExecutor]
209209
) -> None: ...

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='miniirc',
10-
version='1.9.1',
10+
version='1.10.0',
1111
py_modules=['miniirc'],
1212
author='luk3yx',
1313
description='A lightweight IRC framework.',

0 commit comments

Comments
 (0)