1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 04:25:41 +02:00

Initial import

This commit is contained in:
Julien Louis
2006-09-16 20:48:42 +00:00
parent cb95bfc846
commit 0493cb89eb
30 changed files with 4282 additions and 0 deletions
+80
View File
@@ -0,0 +1,80 @@
# --------------------------------------------------------------------
#
# Copyright (c) 2006 by Jean-Marie Favreau <jm@jmtrivial.info>
#
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# --------------------------------------------------------------------
# This script automatically op and voice some nicks
# --------------------------------------------------------------------
import weechat
import re
# regexp list for /op
U_OP = { "server": { "#chan" : [ "nick1@domain.com", "nick2.*@.*"] } }
# chan list where all nicks are /voice
C_VOICE = { "server": [ "#chan1", "#chan2" ] }
def auto_op(server, args):
'''Handle connect'''
result = weechat.PLUGIN_RC_OK
# first, watch if need /op
if U_OP.has_key(server):
chans = U_OP[server]
try:
# find nick and channel
nothing, user, channel = args.split(":")
nick, next = user.split("!")
except ValueError:
result = weechat.PLUGIN_RC_KO
else:
if chans.has_key(channel):
users = chans[channel]
for userExpr in users:
if re.search("^n=" + userExpr, next):
weechat.command("/op "+nick, channel, server) # op nick
weechat.prnt("[op] "+nick+" on "+channel+"("+server+")") # print
return result # exit
# then watch if need /voice
if C_VOICE.has_key(server):
chans = C_VOICE[server]
try:
# find nick and channel
nothing, user, channel = args.split(":")
nick, next = user.split("!")
except ValueError:
result = weechat.PLUGIN_RC_KO
else:
if channel in chans:
weechat.command("/voice "+nick, channel, server) # voice nick
weechat.prnt("[voice] "+nick+" on "+channel+"("+server+")") # print info
return result # exit
# otherwise: nothing to do
return result
# register and add function to weechat
weechat.register("auto_op", "0.2", "", "auto op plug-in for weechat")
weechat.add_message_handler ("join", "auto_op")
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+99
View File
@@ -0,0 +1,99 @@
# -*- coding: iso-8859-15 -*-
"""
:Author: Henning Hasemann <hhasemann [at] web [dot] de>
Usage:
- Load this plugin
- In a channel or query type "/flip foo something" to
send the reversed text "gnihtemos oof"
- In a channel or query type "/leet something else" to
send the h4x02-5r!pT - Version of your text.
(Please use with caution such crap is discouraged in most channels)
Released under GPL licence.
"""
__version__ = "0.1"
__history__ = """
0.1 initial
"""
short_syntax = """TEXT"""
syntax_flip = """ Example:
/flip foo bar
sends "rab oof" to the channel
"""
syntax_leet = """ Example:
/leet eleet
sends "31337" (or similar) to the channel
"""
import weechat as wc
import string, random
wc.register("gimmicks", __version__, "", "string gimmicks")
wc.add_command_handler("flip", "flip", "", short_syntax, syntax_flip)
wc.add_command_handler("leet", "leet", "", short_syntax, syntax_leet)
leet_dict = {
"e": ["3"],
"l": ["1", "!", "|"],
"r": ["|2"],
"b": ["8"],
"v": [r'\/'],
"t": ["7"],
"i": ["!"],
"w": [r'\/\/', 'vv'],
"a": ["/\\", "<|", "4"],
"k": ["x"],
"n": [r'|\|'],
"s": ["5","$"],
"q": ["O."],
"z": ["zZz", "7_"],
"u": ["(_)"],
"p": ["", "|*"],
"d": ["|)", "I>", "ol"],
"f": ["i="],
"g": ["@"],
"h": ["|-|"],
"j": ["_I"],
"y": ["`/"],
"x": ["><"],
"c": ["[", "(", "{"],
"m": ["|v|", "nn"],
"o": ["0", "()"],
}
def leet(server, args):
casechange = True
strange = True
stay = False
r = ""
luflag = 0
for x in list(args):
if stay:
alt = [x]
else:
alt = []
if casechange:
alt.append(luflag and x.lower() or x.upper())
luflag = not luflag
if strange:
alt += leet_dict.get(x.lower(), [])
r += random.choice(alt)
wc.command(r)
return 0
def flip(server, args):
l = list(args)
l.reverse()
wc.command("".join(l))
return 0
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+69
View File
@@ -0,0 +1,69 @@
"""
:Author: Henning Hasemann <hhasemann [at] web [dot] de>
:What it does:
This script listens for messages beginning
with a special token and appends these messages
to a file.
This way people can post you short assignments which
you cant forget and dont have to look up in your look.
(try appending "cat /path/to/mytodofile" at your .bashrc)
:Usage:
- Load this file
- Make sure to set suitable configuration values.
token: The piece of text that signals a TODO
file: The file where the TODOs should be appended
allowed_sources: A space-seperated list of nicknames
which are allowed to send TODOs to you.
- Whenever any allowed person sends a message beginning
with your desired token, the rest of that message is
append to the desired TODO-file.
Released under GPL licence.
"""
__version__ = "0.1"
import weechat as wc
wc.register("todo", __version__, "", "automatic TODO")
wc.add_message_handler("privmsg", "on_msg")
default = {
"token": "##todo ",
"file": "/home/USER/todo",
"allowed_sources": "",
}
for k, v in default.items():
if not wc.get_plugin_config(k):
wc.set_plugin_config(k, v)
def source_allowed(src):
return src in wc.get_plugin_config("allowed_sources").split()
def on_msg(server, args):
# args looks like:
# :foo!foo@host PRIVMSG #channel :Hello, how are you?
token = wc.get_plugin_config("token")
filename = wc.get_plugin_config("file")
try:
nothing, info, message = args.split(":", 2)
hostmask, privmsg, channel = info.split(None, 2)
source = hostmask.split("!")[0]
except ValueError:
# Parsing didnt work,
# this happens mostly when strange messages
# arrive that dont have the format described above
return 0
if source_allowed(source) and message.lower().startswith(token):
wc.print_infobar(5, "NEW TASK: " + str(message[7:]))
f = open(filename, "a")
f.write("%s (%s)\n" % (message[7:], source))
f.close()
return 0
File diff suppressed because it is too large Load Diff
+18
View File
@@ -0,0 +1,18 @@
# This script sends "uname -a" output to current channel.
# Just type /uname while chatting on some channel ;)
# by Stalwart <stlwrt doggy gmail.com>
#
# Released under GPL licence.
import weechat
from os import popen
def senduname(server, args):
unameout = popen ('uname -a')
uname = unameout.readline()
weechat.command(uname[:-1])
return 0
weechat.register ('uname', '1.0', '', """Sends "uname -a" output to current channel""")
weechat.add_command_handler ('uname', 'senduname')
File diff suppressed because it is too large Load Diff