Forked from an-empty-string/identify-msg-check.py
Last active
April 15, 2018 09:39
-
-
Save 0xallie/2fc0dc9b98ba06d800a4 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
# | |
# Copyright 2014-2015, nyuszika7h <nyuszika7h@openmailbox.org> | |
# Copyright 2015, fwilson <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.2' | |
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): | |
if modifier_data != 'freenode': | |
# identify-msg is freenode-specific; disable on other networks | |
# Change this if your "freenode" network is called something else. | |
return | |
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', '') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment