Additional Tools#
- sopel.tools.calculation
- sopel.tools.events
events
events.ERR_ALREADYREGISTERED
events.ERR_ALREADYREGISTRED
events.ERR_BADCHANMASK
events.ERR_BADCHANNELKEY
events.ERR_BADMASK
events.ERR_BANLISTFULL
events.ERR_BANNEDFROMCHAN
events.ERR_CANNOTSENDTOCHAN
events.ERR_CANTKILLSERVER
events.ERR_CHANNELISFULL
events.ERR_CHANOPRIVSNEEDED
events.ERR_ERRONEUSNICKNAME
events.ERR_FILEERROR
events.ERR_INVALIDCAPCMD
events.ERR_INVITEONLYCHAN
events.ERR_KEYINVALID
events.ERR_KEYNOPERMISSION
events.ERR_KEYNOTSET
events.ERR_KEYSET
events.ERR_METADATALIMIT
events.ERR_MONLISTFULL
events.ERR_NEEDMOREPARAMS
events.ERR_NICKCOLLISION
events.ERR_NICKLOCKED
events.ERR_NICKNAMEINUSE
events.ERR_NOADMININFO
events.ERR_NOCHANMODES
events.ERR_NOLOGIN
events.ERR_NOMATCHINGKEY
events.ERR_NOMOTD
events.ERR_NONICKNAMEGIVEN
events.ERR_NOOPERHOST
events.ERR_NOORIGIN
events.ERR_NOPERMFORHOST
events.ERR_NOPRIVILEGES
events.ERR_NORECIPIENT
events.ERR_NOSUCHCHANNEL
events.ERR_NOSUCHNICK
events.ERR_NOSUCHSERVER
events.ERR_NOSUCHSERVICE
events.ERR_NOTEXTTOSEND
events.ERR_NOTONCHANNEL
events.ERR_NOTOPLEVEL
events.ERR_NOTREGISTERED
events.ERR_PASSWDMISMATCH
events.ERR_RESTRICTED
events.ERR_SASLABORTED
events.ERR_SASLALREADY
events.ERR_SASLFAIL
events.ERR_SASLTOOLONG
events.ERR_STARTTLS
events.ERR_SUMMONDISABLED
events.ERR_TARGETINVALID
events.ERR_TOOMANYCHANNELS
events.ERR_TOOMANYTARGETS
events.ERR_UMODEUNKNOWNFLAG
events.ERR_UNAVAILRESOURCE
events.ERR_UNIQOPPRIVSNEEDED
events.ERR_UNKNOWNCOMMAND
events.ERR_UNKNOWNMODE
events.ERR_USERNOTINCHANNEL
events.ERR_USERONCHANNEL
events.ERR_USERSDISABLED
events.ERR_USERSDONTMATCH
events.ERR_WASNOSUCHNICK
events.ERR_WILDTOPLEVEL
events.ERR_YOUREBANNEDCREEP
events.ERR_YOUWILLBEBANNED
events.RPL_ADMINEMAIL
events.RPL_ADMINLOC1
events.RPL_ADMINLOC2
events.RPL_ADMINME
events.RPL_AWAY
events.RPL_BANLIST
events.RPL_BOUNCE
events.RPL_CHANNELMODEIS
events.RPL_CREATED
events.RPL_ENDOFBANLIST
events.RPL_ENDOFEXCEPTLIST
events.RPL_ENDOFINFO
events.RPL_ENDOFINVEXLIST
events.RPL_ENDOFINVITELIST
events.RPL_ENDOFLINKS
events.RPL_ENDOFMONLIST
events.RPL_ENDOFMOTD
events.RPL_ENDOFNAMES
events.RPL_ENDOFSTATS
events.RPL_ENDOFUSERS
events.RPL_ENDOFWHO
events.RPL_ENDOFWHOIS
events.RPL_ENDOFWHOWAS
events.RPL_EXCEPTLIST
events.RPL_INFO
events.RPL_INVEXLIST
events.RPL_INVITELIST
events.RPL_INVITING
events.RPL_ISON
events.RPL_ISUPPORT
events.RPL_KEYVALUE
events.RPL_LINKS
events.RPL_LIST
events.RPL_LISTEND
events.RPL_LISTSTART
events.RPL_LOGGEDIN
events.RPL_LOGGEDOUT
events.RPL_LUSERCHANNELS
events.RPL_LUSERCLIENT
events.RPL_LUSERME
events.RPL_LUSEROP
events.RPL_LUSERUNKNOWN
events.RPL_METADATAEND
events.RPL_MONLIST
events.RPL_MONOFFLINE
events.RPL_MONONLINE
events.RPL_MOTD
events.RPL_MOTDSTART
events.RPL_MYINFO
events.RPL_NAMREPLY
events.RPL_NONE
events.RPL_NOTOPIC
events.RPL_NOUSERS
events.RPL_NOWAWAY
events.RPL_REHASHING
events.RPL_SASLMECHS
events.RPL_SASLSUCCESS
events.RPL_SERVLIST
events.RPL_SERVLISTEND
events.RPL_STARTTLS
events.RPL_STATSCLINE
events.RPL_STATSCOMMANDS
events.RPL_STATSHLINE
events.RPL_STATSILINE
events.RPL_STATSKLINE
events.RPL_STATSLINKINFO
events.RPL_STATSLLINE
events.RPL_STATSNLINE
events.RPL_STATSOLINE
events.RPL_STATSUPTIME
events.RPL_STATSYLINE
events.RPL_SUMMONING
events.RPL_TIME
events.RPL_TOPIC
events.RPL_TRACECLASS
events.RPL_TRACECONNECTING
events.RPL_TRACEEND
events.RPL_TRACEHANDSHAKE
events.RPL_TRACELINK
events.RPL_TRACELOG
events.RPL_TRACENEWTYPE
events.RPL_TRACEOPERATOR
events.RPL_TRACERECONNECT
events.RPL_TRACESERVER
events.RPL_TRACESERVICE
events.RPL_TRACEUNKNOWN
events.RPL_TRACEUSER
events.RPL_TRYAGAIN
events.RPL_UMODEIS
events.RPL_UNAWAY
events.RPL_UNIQOPIS
events.RPL_USERHOST
events.RPL_USERS
events.RPL_USERSSTART
events.RPL_VERSION
events.RPL_WELCOME
events.RPL_WHOISBOT
events.RPL_WHOISCHANNELS
events.RPL_WHOISIDLE
events.RPL_WHOISKEYVALUE
events.RPL_WHOISOPERATOR
events.RPL_WHOISSERVER
events.RPL_WHOISUSER
events.RPL_WHOREPLY
events.RPL_WHOSPCRPL
events.RPL_WHOWASUSER
events.RPL_YOUREOPER
events.RPL_YOURESERVICE
events.RPL_YOURHOST
- sopel.tools.identifiers
- sopel.tools.jobs
- sopel.tools.memories
- sopel.tools.target
Channel
Channel.add_user()
Channel.clear_user()
Channel.has_privilege()
Channel.is_admin()
Channel.is_halfop()
Channel.is_op()
Channel.is_oper()
Channel.is_owner()
Channel.is_voiced()
Channel.join_time
Channel.last_who
Channel.make_identifier
Channel.modes
Channel.name
Channel.privileges
Channel.rename_user()
Channel.topic
Channel.users
User
- sopel.tools.time
- sopel.tools.web
sopel.tools#
Useful miscellaneous tools and shortcuts for Sopel plugins
Availability: 3+
- class sopel.tools.OutputRedirect(logpath, stderr=False, quiet=False)#
Redirect the output to the terminal and a log file.
A simplified object used to write to both the terminal and a log file.
- flush()#
Flush the file writing buffer.
- sopel.tools.chain_loaders(*lazy_loaders)#
Chain lazy loaders into one.
- Parameters:
lazy_loaders (function) – one or more lazy loader functions
- Returns:
a lazy loader that combines all of the given ones
- Return type:
This function takes any number of lazy loaders as arguments and merges them together into one. It’s primarily a helper for lazy rule decorators such as
sopel.plugin.url_lazy()
.Important
This function doesn’t check the uniqueness of regexes generated by all the loaders.
- sopel.tools.get_hostmask_regex(mask)#
Get a compiled regex pattern for an IRC hostmask
- Parameters:
mask (str) – the hostmask that the pattern should match
- Returns:
a compiled regex pattern matching the given
mask
- Return type:
- sopel.tools.get_input(prompt)#
Get decoded input from the terminal (equivalent to Python 3’s
input
).- Parameters:
prompt (str) – what to display as a prompt on the terminal
- Returns:
the user’s input
- Return type:
Deprecated since version 7.1: Use of this function will become a warning when Python 2 support is dropped in Sopel 8.0. The function will be removed in Sopel 8.1.
- sopel.tools.get_logger(plugin_name)#
Return a logger for a plugin.
- Parameters:
plugin_name (str) – name of the plugin
- Returns:
the logger for the given plugin
This:
from sopel import tools LOGGER = tools.get_logger('my_custom_plugin')
is equivalent to this:
import logging LOGGER = logging.getLogger('sopel.externals.my_custom_plugin')
Internally, Sopel configures logging for the
sopel
namespace, so external plugins can’t benefit from it withlogging.getLogger(__name__)
as they won’t be in the same namespace. This function uses theplugin_name
with a prefix inside this namespace.New in version 7.0.
- sopel.tools.get_sendable_message(text, max_length=400)#
Get a sendable
text
message, with its excess when needed.- Parameters:
- Returns:
a tuple of two values, the sendable text and its excess text
- Return type:
We’re arbitrarily saying that the (default) max is 400 bytes of text when messages will be split, but callers can specify a different value (e.g. to account precisely for the bot’s hostmask).
The
max_length
is the max length of text in bytes, but we take care of multibyte UTF-8 characters by working on the Unicode string, then making sure the bytes version is smaller than the max length.New in version 6.6.2.