-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_join.py
49 lines (41 loc) · 1.9 KB
/
add_join.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
# A script to spam a series of messages in an irc channel
# Copyright (c) 2012 Ivan Sichmann Freitas, Sergio Durigan Junior
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import weechat as w
import re
w.register("add_join", "Ivan Sichmann Freitas, Sergio Durigan Junior", "0.2", "GPL3",
"Add a channel to the autojoin list", "", "")
def append_channel(data, buffer, args):
buffer_name = w.buffer_get_string(buffer, "short_name")
server_name = w.buffer_get_string(buffer, "name").split(".")[0]
config = "irc.server.%s.autojoin" % (server_name)
channels = w.config_string(w.config_get(config))
if (args != "" and args in channels) or (buffer_name in channels):
w.prnt ('', "The channel %s is already present in the list." % buffer_name)
return w.WEECHAT_RC_OK
if args == "":
channels = channels + "," + buffer_name
else:
channels = channels + "," + args
w.command('', "/set irc.server.%s.autojoin %s" % (server_name, channels))
return w.WEECHAT_RC_OK
w.hook_command("append_join",
"Append a channel to the autojoin list",
"[<channel>]",
"channel: name of the appended channel\n"
"without arguments add the current buffer",
"",
"append_channel",
"")