mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 20:22:45 +01:00
RSS: Make feed announces actually network-specific
.getSpecific() always returned the channel-specific but non-network-specific var, unless the channel-specific and network-specific one was manually set.
This commit is contained in:
parent
40155ede22
commit
dcca9f9637
@ -575,7 +575,8 @@ class RSS(callbacks.Plugin):
|
|||||||
S = announce.getSpecific(channel=channel, network=irc.network)()
|
S = announce.getSpecific(channel=channel, network=irc.network)()
|
||||||
for name in feeds:
|
for name in feeds:
|
||||||
S.add(name)
|
S.add(name)
|
||||||
announce.getSpecific(channel=channel, network=irc.network).setValue(S)
|
announce.getSpecific(channel=channel, network=irc.network,
|
||||||
|
fallback_to_channel=False).setValue(S)
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
for name in feeds:
|
for name in feeds:
|
||||||
feed = plugin.get_feed(name)
|
feed = plugin.get_feed(name)
|
||||||
@ -606,7 +607,7 @@ class RSS(callbacks.Plugin):
|
|||||||
|
|
||||||
remove_from_var(announce.get(channel))
|
remove_from_var(announce.get(channel))
|
||||||
remove_from_var(announce.getSpecific(
|
remove_from_var(announce.getSpecific(
|
||||||
channel=channel, network=irc.network))
|
channel=channel, network=irc.network, fallback_to_channel=False))
|
||||||
|
|
||||||
irc.replySuccess()
|
irc.replySuccess()
|
||||||
remove = wrap(remove, [('checkChannelCapability', 'op'),
|
remove = wrap(remove, [('checkChannelCapability', 'op'),
|
||||||
|
@ -381,13 +381,21 @@ class Value(Group):
|
|||||||
e.value = self
|
e.value = self
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
def getSpecific(self, network=None, channel=None, check=True):
|
def getSpecific(self, network=None, channel=None, check=True,
|
||||||
|
fallback_to_channel=True):
|
||||||
"""Gets the network-specific and/or channel-specific value of this
|
"""Gets the network-specific and/or channel-specific value of this
|
||||||
Value.
|
Value.
|
||||||
If `check=True` (the default), this will raise an error if `network`
|
If ``check=True`` (the default), this will raise an error if ``network``
|
||||||
(resp. `channel`) is provided but this Value is not network-specific
|
(resp. ``channel``) is provided but this Value is not network-specific
|
||||||
(resp. channel-specific). If `check=False`, then `network` and/or
|
(resp. channel-specific). If ``check=False``, then ``network`` and/or
|
||||||
`channel` may be silently ignored.
|
``channel`` may be silently ignored.
|
||||||
|
|
||||||
|
If ``fallback_to_channel=True`` (the default) and the network-specific
|
||||||
|
+ channel-specific value is not set, but the channel-specific value is
|
||||||
|
set, it will return the latter.
|
||||||
|
This is useful to upgrade from existing bot configuration, that did not
|
||||||
|
support network-specific values; but it may be undesirable when setting
|
||||||
|
new values.
|
||||||
"""
|
"""
|
||||||
if network and not self._networkValue:
|
if network and not self._networkValue:
|
||||||
if check:
|
if check:
|
||||||
@ -452,6 +460,7 @@ class Value(Group):
|
|||||||
# 3. it's inherited from the chan specific value (which is not a
|
# 3. it's inherited from the chan specific value (which is not a
|
||||||
# actually a parent in the registry tree, but we need this to
|
# actually a parent in the registry tree, but we need this to
|
||||||
# load configuration from old bots).
|
# load configuration from old bots).
|
||||||
|
# 4. it was never set at all
|
||||||
#
|
#
|
||||||
# The choice between 2 and 3 is done by checking which of the
|
# The choice between 2 and 3 is done by checking which of the
|
||||||
# net-specific and chan-specific values was set explicitly by
|
# net-specific and chan-specific values was set explicitly by
|
||||||
@ -464,9 +473,12 @@ class Value(Group):
|
|||||||
if network_value._wasSet or network_channel_value._wasSet:
|
if network_value._wasSet or network_channel_value._wasSet:
|
||||||
# cases 1 and 2
|
# cases 1 and 2
|
||||||
return network_channel_value
|
return network_channel_value
|
||||||
else:
|
elif channel_value._wasSet and fallback_to_channel:
|
||||||
# case 3
|
# case 3
|
||||||
return channel_value
|
return channel_value
|
||||||
|
else:
|
||||||
|
# case 4
|
||||||
|
return network_channel_value
|
||||||
elif network:
|
elif network:
|
||||||
return self.get(':' + network)
|
return self.get(':' + network)
|
||||||
elif channel:
|
elif channel:
|
||||||
|
Loading…
Reference in New Issue
Block a user