This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/correction.py

31 lines
1.2 KiB
Python
Raw Normal View History

from util import hook
@hook.regex(r'^(s|S)/.*/.*/\S*$')
2013-10-01 05:55:18 +02:00
def correction(inp, message=None, input=None, notice=None, db=None):
splitinput = input.msg.split("/")
if splitinput[3]:
nick = splitinput[3]
else:
nick = input.nick
last_message = db.execute("select name, quote from seen_user where name"
" like ? and chan = ?", (nick.lower(), input.chan.lower())).fetchone()
if last_message:
splitinput = input.msg.split("/")
find = splitinput[1]
replace = splitinput[2]
if find in last_message[1]:
if "\x01ACTION" in last_message[1]:
message = last_message[1].replace("\x01ACTION ", "/me ").replace("\x01", "")
else:
message = last_message[1]
2013-10-08 00:32:17 +02:00
message(u"{} meant to say: {}".format(message.replace(find, "\x02" + replace + "\x02"), nick))
else:
2013-10-08 00:32:17 +02:00
notice(u"{} can't be found in your last message".format(find))
else:
2013-08-11 01:47:54 +02:00
if nick == input.nick:
2013-10-08 00:32:17 +02:00
notice(u"I haven't seen you say anything here yet")
else:
2013-10-08 00:32:17 +02:00
notice(u"I haven't seen {} say anything here yet".format(nick))