Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import weechat
- import time
- weechat.register("redirect_script", "ChatGPT", "1.0", "GPL3", "Redirect NOTICE and WHOIS responses to current buffer", "", "")
- def notice_redirect(data, signal, signal_data):
- parsed = weechat.info_get_hashtable("irc_message_parse", {"message": signal_data})
- nick, host = parsed["host"].split('!', 1)
- buffer = weechat.current_buffer()
- weechat.prnt(buffer, "{}Notice from {}{}{} ({}): {}{}".format(weechat.color("magenta"), weechat.color("yellow"), nick, weechat.color("reset"), host, weechat.color("magenta"), parsed["arguments"].split(" :", 1)[1]))
- return weechat.WEECHAT_RC_OK
- def whois_redirect(data, signal, signal_data):
- parsed = weechat.info_get_hashtable("irc_message_parse", {"message": signal_data})
- whois_codes = ["311", "312", "313", "317", "318", "319", "320", "324", "330", "335", "378", "379", "671"]
- if parsed["command"] in whois_codes:
- buffer = weechat.current_buffer()
- args = parsed["arguments"].split(" ")
- if len(args) >= 2:
- nick = args[1]
- args_remaining = " ".join(args[2:])
- if parsed["command"] == "311": # Start of WHOIS responses
- weechat.prnt(buffer, "\n{}[{}]{} {}@{}{}".format(weechat.color("magenta"), nick, weechat.color("reset"), args[2], weechat.color("yellow"), " ".join(args[3:])))
- elif parsed["command"] == "319": # Channels the user is on
- weechat.prnt(buffer, "{}[{}]{} {}".format(weechat.color("magenta"), nick, weechat.color("yellow"), " ".join(args[2:])))
- elif parsed["command"] == "317": # Idle time and signon time
- idle_seconds = int(args[2])
- idle_hours = idle_seconds // 3600
- idle_minutes = (idle_seconds % 3600) // 60
- idle_seconds = idle_seconds % 60
- signon_time = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime(int(args[3])))
- weechat.prnt(buffer, "{}[{}]{} idle: {:02d} hours {:02d} minutes {:02d} seconds, signon at: {}".format(weechat.color("magenta"), nick, weechat.color("reset"), idle_hours, idle_minutes, idle_seconds, signon_time))
- else:
- weechat.prnt(buffer, "{}[{}]{} {}".format(weechat.color("magenta"), nick, weechat.color("reset"), " ".join(args[2:])))
- return weechat.WEECHAT_RC_OK
- weechat.hook_signal("*,irc_in_notice", "notice_redirect", "")
- weechat.hook_signal("*,irc_in2_*", "whois_redirect", "")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement