Last active
July 17, 2024 19:15
-
-
Save an-empty-string/f0455ff4371e9515ed54 to your computer and use it in GitHub Desktop.
identify-msg checkmark for weechat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2014-2015, nyuszika7h <nyuszika7h@openmailbox.org> (and fwilson, maybe. <fwilson@fwilson.me>) | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is | |
# furnished to do so, subject to the following conditions: | |
# | |
# The above copyright notice and this permission notice shall be included in | |
# all copies or substantial portions of the Software. | |
# | |
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
# THE SOFTWARE. | |
# Make sure you request the identify-msg capability from the server! | |
# /quote cap req identify-msg | |
# or set the appropriate server option | |
import weechat | |
SCRIPT_NAME = 'identify-msg-checkmark' | |
SCRIPT_AUTHOR = 'fwilson' | |
SCRIPT_VERSION = '0.42.1' | |
SCRIPT_LICENSE = 'MIT' | |
SCRIPT_DESC = 'identify-msg support for weechat, based on sillynet-ident-msg by nyuszika7h' | |
weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, | |
SCRIPT_DESC, '', '') | |
def privmsg_modifier_cb(data, modifier, modifier_data, string): | |
string_tokens = string.split(' ') | |
hostmask = string.split(':')[1].split(' ')[0] | |
if '!' not in hostmask or '@' not in hostmask: | |
return string | |
nick, ident = hostmask.split('!') | |
ident, host = ident.split('@') | |
ident = ident.lstrip('~') | |
message = ' '.join(string_tokens[3:])[1:] | |
channel = string_tokens[2] | |
if channel[0] != "#": | |
checkmark = "" | |
else: | |
checkmark = '✓' if message[0] == '+' else '✗' | |
return (':%s%s!%s@%s PRIVMSG %s :%s' % | |
(checkmark, nick, ident, host, channel, message[1:])) | |
weechat.hook_modifier('irc_in_privmsg', 'privmsg_modifier_cb', '') |
The script should probably check whether identify-msg
is enabled first.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just do this: