2017-03-13 17:30:06 +01:00
|
|
|
# global.py: Global Noticing Plugin
|
|
|
|
|
2017-03-13 21:38:53 +01:00
|
|
|
import string
|
|
|
|
|
2017-03-13 17:30:06 +01:00
|
|
|
from pylinkirc import conf, utils, world
|
|
|
|
from pylinkirc.log import log
|
|
|
|
from pylinkirc.coremods import permissions
|
|
|
|
|
2017-03-13 21:38:53 +01:00
|
|
|
DEFAULT_FORMAT = "[$sender@$fullnetwork] $text"
|
|
|
|
|
2017-03-13 17:30:06 +01:00
|
|
|
def g(irc, source, args):
|
|
|
|
"""<message text>
|
2017-03-13 21:29:04 +01:00
|
|
|
|
2017-03-13 17:30:06 +01:00
|
|
|
Sends out a Instance-wide notice.
|
|
|
|
"""
|
|
|
|
permissions.checkPermissions(irc, source, ["global.global"])
|
|
|
|
message = " ".join(args)
|
2017-03-13 21:38:53 +01:00
|
|
|
template = string.Template(conf.conf.get('global', {}).get("format", DEFAULT_FORMAT))
|
|
|
|
|
2017-03-13 17:30:06 +01:00
|
|
|
for name, ircd in world.networkobjects.items():
|
2017-03-13 21:23:22 +01:00
|
|
|
if ircd.connected.is_set(): # Only attempt to send to connected networks
|
|
|
|
for channel in ircd.pseudoclient.channels:
|
2017-06-30 08:01:39 +02:00
|
|
|
subst = {'sender': irc.get_friendly_name(source),
|
2017-03-13 21:38:53 +01:00
|
|
|
'network': irc.name,
|
2017-06-30 08:01:39 +02:00
|
|
|
'fullnetwork': irc.get_full_network_name(),
|
2017-03-13 21:38:53 +01:00
|
|
|
'current_channel': channel,
|
|
|
|
'current_network': ircd.name,
|
2017-06-30 08:01:39 +02:00
|
|
|
'current_fullnetwork': ircd.get_full_network_name(),
|
2017-03-13 21:38:53 +01:00
|
|
|
'text': message}
|
|
|
|
|
2017-03-13 21:29:04 +01:00
|
|
|
# Disable relaying or other plugins handling the global message.
|
2017-03-13 21:38:53 +01:00
|
|
|
ircd.msg(channel, template.safe_substitute(subst), loopback=False)
|
2017-03-13 21:29:04 +01:00
|
|
|
|
2017-03-13 17:30:06 +01:00
|
|
|
|
|
|
|
utils.add_cmd(g, "global", featured=True)
|