mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-23 19:19:31 +01:00
commit
4910355711
@ -60,6 +60,9 @@ Remote versions of the `manage`, `list`, `sync`, and `clear` commands also exist
|
||||
- `exec.raw` - Allows access to the `raw` command.
|
||||
- `exec.inject` - Allows access to the `inject` command.
|
||||
|
||||
## Global
|
||||
- `global.global` - Allows access to the `global` command.
|
||||
|
||||
## Networks
|
||||
- `networks.disconnect` - Allows access to the `disconnect` command.
|
||||
- `networks.autoconnect` - Allows access to the `autoconnect` command.
|
||||
|
@ -418,6 +418,10 @@ plugins:
|
||||
# of kills/saves per X seconds is met.
|
||||
#- servprotect
|
||||
|
||||
# Global plugin: Janus-style global plugin; announces messages to all channels the PyLink
|
||||
# client is in.
|
||||
#- global
|
||||
|
||||
logging:
|
||||
# This configuration block defines targets that PyLink should log commands,
|
||||
# errors, etc., to.
|
||||
@ -665,3 +669,16 @@ stats:
|
||||
# Determines the time format that the Stats plugin should use for showing dates + times.
|
||||
# Defaults to "%a, %d %b %Y %H:%M:%S +0000" (the RFC 2812 standard) if not specified.
|
||||
time_format: "%c"
|
||||
|
||||
global:
|
||||
# Sets the text format for the global plugin, if it is loaded. This uses a template string as
|
||||
# documented at https://docs.python.org/3/library/string.html#template-strings, with the
|
||||
# following substitutions:
|
||||
# $sender: the nick of the sender
|
||||
# $network: the short network name of the origin network
|
||||
# $fullnetwork: the full network name of the origin network
|
||||
# $current_channel: the channel we're broadcasting on
|
||||
# $current_network: the network we're currently broadcasting on
|
||||
# $current_fullnetwork: the full name of the network we're currently broadcasting on
|
||||
# $text: the global text
|
||||
#format: "[$sender@$fullnetwork] $text"
|
||||
|
35
plugins/global.py
Normal file
35
plugins/global.py
Normal file
@ -0,0 +1,35 @@
|
||||
# global.py: Global Noticing Plugin
|
||||
|
||||
import string
|
||||
|
||||
from pylinkirc import conf, utils, world
|
||||
from pylinkirc.log import log
|
||||
from pylinkirc.coremods import permissions
|
||||
|
||||
DEFAULT_FORMAT = "[$sender@$fullnetwork] $text"
|
||||
|
||||
def g(irc, source, args):
|
||||
"""<message text>
|
||||
|
||||
Sends out a Instance-wide notice.
|
||||
"""
|
||||
permissions.checkPermissions(irc, source, ["global.global"])
|
||||
message = " ".join(args)
|
||||
template = string.Template(conf.conf.get('global', {}).get("format", DEFAULT_FORMAT))
|
||||
|
||||
for name, ircd in world.networkobjects.items():
|
||||
if ircd.connected.is_set(): # Only attempt to send to connected networks
|
||||
for channel in ircd.pseudoclient.channels:
|
||||
subst = {'sender': irc.getFriendlyName(source),
|
||||
'network': irc.name,
|
||||
'fullnetwork': irc.getFullNetworkName(),
|
||||
'current_channel': channel,
|
||||
'current_network': ircd.name,
|
||||
'current_fullnetwork': ircd.getFullNetworkName(),
|
||||
'text': message}
|
||||
|
||||
# Disable relaying or other plugins handling the global message.
|
||||
ircd.msg(channel, template.safe_substitute(subst), loopback=False)
|
||||
|
||||
|
||||
utils.add_cmd(g, "global", featured=True)
|
Loading…
Reference in New Issue
Block a user