3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-23 10:44:09 +01:00

Merge branch 'devel' into wip/p10

This commit is contained in:
James Lu 2016-04-16 17:04:32 -07:00
commit fccfb62609
4 changed files with 25 additions and 21 deletions

View File

@ -1,27 +1,27 @@
/* Graph for the PyLink Application Structure:
* Update using: dot -Tpng core-structure.dot > core-structure.png
*/
digraph G {
ratio = 1.3;
ratio = 0.8; /* make the graph wider than tall */
subgraph cluster_core {
label="PyLink Application Structure";
style="filled";
node [style="filled",color="white"];
color="lightblue";
subgraph cluster_testsuite {
label="Test Suite API";
style="filled";
node [style="filled",color="white"];
color=moccasin;
"Dummy protocol\nmodule" -> "Dummy IRC\nobject (FakeIRC)" [color=darkgreen];
"Dummy IRC\nobject (FakeIRC)" -> "Dummy protocol\nmodule" [color=darkgreen];
}
"IRC object" -> "Protocol module" -> "PyLink hooks" -> Plugins;
"Main program" -> "IRC object" [color=indigo] [label="Spawns 1/net"] [fontcolor=indigo];
"Main program" -> "Dummy IRC\nobject (FakeIRC)" [color=darkgreen] [label="(test suite runner)"] [fontcolor=darkgreen];
"IRC objects" -> "Protocol modules" [label="Data relayed"]
"Protocol modules" -> "PyLink hooks" -> Plugins;
"IRC objects" -> "PyLink hooks";
"Main program" -> "IRC objects" [color=indigo] [label="One per network\nspawned"] [fontcolor=indigo];
"Main program" -> "IRC objects" [color=indigo];
"Main program" -> "IRC objects" [color=indigo];
"Protocol modules" -> "IRC objects" [label="States updated"] [color=darkgreen] [fontcolor=darkgreen];
"Main program" -> Plugins [label="Plugin loaders"];
}
"Protocol module" -> "Remote IRCd" -> "Protocol module";
Plugins -> "Protocol module" [label="Communicates \nvia*Client/*Server\nfunctions"] [color=navyblue] [fontcolor=navyblue];
"Protocol modules" -> "IRCds" -> "Protocol modules";
Plugins -> "Protocol modules" [label="Communication via\nIRC command\nsenders"] [color=navyblue] [fontcolor=navyblue];
Plugins -> "Main program" [label="Registers commands\n& hook handlers"] [color=brown] [fontcolor=brown];
"Dummy protocol\nmodule" -> "PyLink hooks" [color=darkgreen];
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

@ -112,23 +112,23 @@ When receiving or sending topics, there is a `topicset` attribute in the IRC cha
### Mode formats
Modes are stored a special format in PyLink, different from raw mode strings in order to make them easier to parse. Mode strings can be turned into mode *lists*, which are used to both represent mode changes in hooks, and when storing them internally.
Modes are stored a special format in PyLink, different from raw mode strings in order to make them easier to parse. Mode strings can be turned into mode *lists*, which are used to represent mode changes in hooks, and when storing modes internally.
`utils.parseModes(irc, target, split_modestring)` is used to convert mode strings to mode lists, where `irc` is the IRC object, `target` is the channel or user the mode is being set on, and `split_modestring` is the string of modes to parse, *split at each space* (really a list).
`utils.parseModes(irc, target, split_modestring)` is used to convert mode strings to mode lists, where `irc` is the IRC object, `target` is the channel name or UID the mode is being set on, and `split_modestring` is the string of modes to parse, *split at each space* (meaning that it's really a list).
- `utils.parseModes(irc, '#chat', ['+tHIs', '*!*@is.sparta'])` would give:
- `[('+t', None), ('+H', None), ('+I', '*!*@is.sparta'), ('+s', None)]`
Also, it will automatically convert prefix mode targets from nicks to UIDs, and drop invalid modes
Also, `parseModes` will automatically convert prefix mode targets from nicks to UIDs, and drop invalid modes settings.
- `utils.parseModes(irc, '#chat', ['+ol', 'invalidnick'])`:
- `[]`
- `utils.parseModes(irc, '#chat', ['+o', 'GLolol'])`:
- `[('+o', '001ZJZW01')]`
Then, the parsed mode lists can be applied to channel using `utils.applyModes(irc, target, parsed_modelist)`.
Then, a parsed mode list can be applied to channel name or UID using `utils.applyModes(irc, target, parsed_modelist)`.
Modes are stored in channels and users as sets: `(userobj or chanobj).modes`:
Internally, modes are stored in channel and user objects as sets: `(userobj or chanobj).modes`:
```
<+GLolol> PyLink-devel, eval irc.users[source].modes
@ -141,7 +141,7 @@ Modes are stored in channels and users as sets: `(userobj or chanobj).modes`:
```
<@GLolol> PyLink-devel, eval irc.channels['#chat'].prefixmodes
<+PyLink-devel> {'ops': set(), 'halfops': set(), 'voices': {'38QAAAAAA'}, 'owners': set(), 'admins': set()}
<+PyLink-devel> {'op': set(), 'halfop': set(), 'voice': {'38QAAAAAA'}, 'owner': set(), 'admin': set()}
```
When a certain mode (e.g. owner) isn't supported on a network, the key still exists in `prefixmodes` but is simply unused.

View File

@ -481,6 +481,10 @@ class TS6Protocol(TS6BaseProtocol):
else:
channel = utils.toLower(self.irc, args[1])
self.updateTS(channel, ts)
self.irc.users[numeric].channels.add(channel)
self.irc.channels[channel].users.add(numeric)
# We send users and modes here because SJOIN and JOIN both use one hook,
# for simplicity's sake (with plugins).
return {'channel': channel, 'users': [numeric], 'modes':