mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
automode: mangle channels to "#chanid" on networks where they're stored as int
This allows the bulk of automode's commands to actually function.
This commit is contained in:
parent
d28a9681ac
commit
41497a8a13
@ -3,6 +3,7 @@ automode.py - Provide simple channel ACL management by giving prefix modes to us
|
|||||||
hostmasks or exttargets.
|
hostmasks or exttargets.
|
||||||
"""
|
"""
|
||||||
import collections
|
import collections
|
||||||
|
import string
|
||||||
|
|
||||||
from pylinkirc import conf, structures, utils, world
|
from pylinkirc import conf, structures, utils, world
|
||||||
from pylinkirc.coremods import permissions
|
from pylinkirc.coremods import permissions
|
||||||
@ -97,6 +98,8 @@ def match(irc, channel, uids=None):
|
|||||||
Set modes on matching users. If uids is not given, check all users in the channel and give
|
Set modes on matching users. If uids is not given, check all users in the channel and give
|
||||||
them modes as needed.
|
them modes as needed.
|
||||||
"""
|
"""
|
||||||
|
if isinstance(channel, int) or str(channel).startswith(tuple(string.digits)):
|
||||||
|
channel = '#' + str(channel) # Mangle channels on networks where they're stored as an ID
|
||||||
dbentry = db.get(irc.name+channel)
|
dbentry = db.get(irc.name+channel)
|
||||||
if not irc.has_cap('has-irc-modes'):
|
if not irc.has_cap('has-irc-modes'):
|
||||||
log.debug('(%s) automode: skipping match() because IRC modes are not supported on this protocol', irc.name)
|
log.debug('(%s) automode: skipping match() because IRC modes are not supported on this protocol', irc.name)
|
||||||
@ -169,6 +172,10 @@ def _get_channel_pair(irc, source, chanpair, perm=None):
|
|||||||
Fetches the network and channel given a channel pair, also optionally checking the caller's permissions.
|
Fetches the network and channel given a channel pair, also optionally checking the caller's permissions.
|
||||||
"""
|
"""
|
||||||
log.debug('(%s) Looking up chanpair %s', irc.name, chanpair)
|
log.debug('(%s) Looking up chanpair %s', irc.name, chanpair)
|
||||||
|
|
||||||
|
if '#' not in chanpair and chanpair.startswith(tuple(string.digits)):
|
||||||
|
chanpair = '#' + chanpair # Mangle channels on networks where they're stored by ID
|
||||||
|
|
||||||
try:
|
try:
|
||||||
network, channel = chanpair.split('#', 1)
|
network, channel = chanpair.split('#', 1)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user