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/attacks.py

123 lines
3.2 KiB
Python
Raw Normal View History

2012-02-29 08:31:42 +01:00
from util import hook
import random
2012-03-26 07:32:20 +02:00
with open("plugins/data/larts.txt") as f:
2012-05-09 21:54:30 +02:00
larts = [line.strip() for line in f.readlines()
if not line.startswith("//")]
2012-03-26 07:32:20 +02:00
with open("plugins/data/slaps.txt") as f:
2012-05-09 21:54:30 +02:00
slaps = [line.strip() for line in f.readlines()
2012-05-09 23:18:51 +02:00
if not line.startswith("//")]
with open("plugins/data/slap_items.txt") as f:
2012-05-09 23:18:51 +02:00
items = [line.strip() for line in f.readlines()
if not line.startswith("//")]
2012-03-26 07:32:20 +02:00
with open("plugins/data/kills.txt") as f:
2012-05-09 21:54:30 +02:00
kills = [line.strip() for line in f.readlines()
if not line.startswith("//")]
2012-03-26 07:32:20 +02:00
2013-08-01 00:36:47 +02:00
with open("plugins/data/insults.txt") as f:
insults = [line.strip() for line in f.readlines()
if not line.startswith("//")]
with open("plugins/data/flirts.txt") as f:
flirts = [line.strip() for line in f.readlines()
if not line.startswith("//")]
@hook.command
2012-03-26 07:11:22 +02:00
def slap(inp, me=None, nick=None, conn=None, notice=None):
2013-09-04 12:30:04 +02:00
"""slap <user> -- Makes the bot slap <user>."""
target = inp.strip()
if " " in target:
notice("Invalid username!")
return
2012-03-26 07:11:22 +02:00
# if the user is trying to make the bot slap itself, slap them
if target.lower() == conn.nick.lower() or target.lower() == "itself":
2012-03-26 07:11:22 +02:00
target = nick
2012-04-02 18:17:55 +02:00
values = {"item": random.choice(items), "user": target}
phrase = random.choice(slaps)
2012-04-02 18:17:55 +02:00
2012-03-26 07:11:22 +02:00
# act out the message
me(phrase.format(**values))
2012-02-29 08:31:42 +01:00
@hook.command
2012-03-26 07:11:22 +02:00
def lart(inp, me=None, nick=None, conn=None, notice=None):
2013-09-04 12:30:04 +02:00
"""lart <user> -- LARTs <user>."""
2012-10-17 23:03:17 +02:00
target = inp.strip()
2012-02-29 08:31:42 +01:00
2012-10-17 23:03:17 +02:00
if " " in target:
2012-02-29 08:31:42 +01:00
notice("Invalid username!")
return
2012-10-17 23:03:17 +02:00
# if the user is trying to make the bot slap itself, slap them
if target.lower() == conn.nick.lower() or target.lower() == "itself":
target = nick
2012-04-02 18:17:55 +02:00
2012-10-17 23:03:17 +02:00
values = {"user": target}
phrase = random.choice(larts)
# act out the message
me(phrase.format(**values))
@hook.command
2012-03-26 07:11:22 +02:00
def kill(inp, me=None, nick=None, conn=None, notice=None):
2013-09-04 12:30:04 +02:00
"""kill <user> -- Makes the bot kill <user>."""
2012-10-17 20:52:58 +02:00
target = inp.strip()
2012-10-17 20:52:58 +02:00
if " " in target:
notice("Invalid username!")
return
2012-10-17 20:52:58 +02:00
# if the user is trying to make the bot slap itself, slap them
if target.lower() == conn.nick.lower() or target.lower() == "itself":
target = nick
2012-04-02 18:17:55 +02:00
2012-10-17 20:52:58 +02:00
values = {"user": target}
phrase = random.choice(kills)
# act out the message
me(phrase.format(**values))
2013-08-01 00:36:47 +02:00
@hook.command
def insult(inp, nick=None, me=None, conn=None, notice=None):
2013-09-04 12:30:04 +02:00
"""insult <user> -- Makes the bot insult <user>."""
2013-08-01 00:36:47 +02:00
target = inp.strip()
if " " in target:
notice("Invalid username!")
return
if target == conn.nick.lower() or target == "itself":
target = nick
else:
target = inp
out = 'insults %s... "%s"' % (target, random.choice(insults))
me(out)
@hook.command
2013-09-04 12:30:04 +02:00
def flirt(inp, me=None, conn=None, notice=None):
"""flirt <user> -- Make the bot flirt with <user>."""
2013-08-01 00:36:47 +02:00
target = inp.strip()
if " " in target:
notice("Invalid username!")
return
if target == conn.nick.lower() or target == "itself":
target = 'itself'
else:
target = inp
out = 'flirts with %s... "%s"' % (target, random.choice(flirts))
me(out)