Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import weechat
- import re
- SCRIPT_NAME = "discord_disinfectant"
- SCRIPT_AUTHOR = "Ben"
- SCRIPT_VERSION = "0.1"
- SCRIPT_LICENSE = "GPL3"
- SCRIPT_DESC = "Make IRC great again"
- discord_bot_names = ["RHDiscord", "RHDiscord1", "RHDiscord2", "RHDiscord3", "RHBridge", "RHBridge1", "RHBridge2"]
- #build an re
- pattern = ".*" + "|.*".join(discord_bot_names)
- bot_filter = re.compile(pattern)
- def strip_discord(data, modifier, modifier_data, line):
- full_name = modifier_data.split(';')[1]
- channel = '.'.join(full_name.split('.')[1:])
- if channel != "#ravenholdt":
- return line
- nick, message = line.split("\t")
- if bot_filter.match(nick):
- #f nick == "RHBridge":
- strings = re.split("(^<.*?>)", message, maxsplit=1)
- #weechat.prnt("", str(strings))
- if strings[0] == "":
- name = strings[1]
- message = strings[2]
- else:
- name = ""
- message = strings[0]
- return "%s%s\t%s" % (weechat.info_get("nick_color", name), name, message)
- else:
- return line
- return line
- if __name__ == "__main__":
- if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
- weechat.hook_modifier("weechat_print", "strip_discord", "")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement