Skip to content

Commit d708c55

Browse files
jessemcdowellflashcode
authored andcommitted
New script irccloud_avatar_link.py: add IRCCloud avatar image link to WHOIS output
1 parent b7b6e8a commit d708c55

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

python/irccloud_avatar_link.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#
2+
# Copyright (9) 2024 Jesse McDowell <[email protected]>
3+
#
4+
# Add IRCCloud avatar image link to WHOIS output
5+
#
6+
# This program is free software: you can redistribute it and/or modify it under the terms of the
7+
# GNU General Public License as published by the Free Software Foundation, either version 3 of the
8+
# License, or (at your option) any later version.
9+
#
10+
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
11+
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License along with this program. If not,
15+
# see <https://www.gnu.org/licenses/>.
16+
#
17+
# 2024-08-25: Jesse McDowell
18+
# version 1.0: Initial release
19+
20+
21+
try:
22+
import weechat
23+
from weechat import WEECHAT_RC_OK
24+
import_ok = True
25+
except ImportError:
26+
print('This script must be run under WeeChat.')
27+
import_ok = False
28+
29+
import re
30+
31+
def whois311_cb(data, signal, signal_data):
32+
buffer = weechat.info_get("irc_buffer", signal.split(",")[0])
33+
34+
userid_text = signal_data.split(" ")[5 if signal_data[0] == "@" else 4]
35+
36+
userid_match = userid_expression.match(userid_text)
37+
if userid_match is not None:
38+
weechat.prnt(buffer, "Avatar image: https://static.irccloud-cdn.com/avatar-redirect/%s" % userid_match.groups()[0])
39+
40+
return WEECHAT_RC_OK
41+
42+
if __name__ == '__main__' and import_ok:
43+
weechat.register("irccloud_avatar_link", "Jesse McDowell", "1.0", "GPL3", "Add IRCCloud avatar image link to WHOIS details", "", "")
44+
userid_expression = re.compile("^[us]id([0-9]+)$")
45+
46+
weechat.hook_signal("*,irc_in2_311", "whois311_cb", "")

0 commit comments

Comments
 (0)