Skip to content
Permalink
Browse files

Ignore users is now possible

  • Loading branch information...
noqqe authored and System administrator committed Sep 5, 2016
1 parent e64e9ae commit 2aab3890a76e64630fd023f276f354137d59de18
@@ -94,6 +94,12 @@ id = voE

Optionen für Sprache: "de" oder "en"

# Ignore

List of users to ignore. Separated by comma.

user1,user2

# Sentences

Wenn man den Bot im Chat mit "Rezeptionistin" anspricht, wird das Sentences
@@ -5,6 +5,7 @@ nick = Rezeptionistin
ircchan = #k4cg
debugchan = #k4cgdebug
nickservpassword = passw0rd
ignore = user1,user2

[HTTP]
useragent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/600.6.3 (KHTML, like Gecko) Version/8.0.6 Safari/600.6.3
@@ -6,9 +6,9 @@ def help_text(self, bot):

def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!gt'):
bot.send_message(channel, bot.translate("alive_str1").format(nick=user_nick))
bot.send_message(channel, bot.translate("alive_str1").format(nick=user_nick), user_nick)

def on_privmsg(self, bot, user_nick, host, message):
if message.lower().startswith('!gt'):
bot.send_message(user_nick, bot.translate("alive_str1").format(nick=user_nick))
bot.send_message(user_nick, bot.translate("alive_str1").format(nick=user_nick), user_nick)

@@ -4,17 +4,17 @@
class Eightball(Plugin):
def help_text(self, bot):
return bot.translate("eightball_help")

def answer(self, bot, msg, recipient, nick=None):
keywords = ["kann ich", "darf ich", "soll ich", "muss ich"]
if any(msg.lower().startswith(k) for k in keywords):
adressee = (nick + ": ") if nick else ""

if "oder" in msg:
bot.send_message(recipient, adressee + random.choice(list(open('lists/alternate_answers.txt'))))
bot.send_message(recipient, adressee + random.choice(list(open('lists/alternate_answers.txt'))), nick)
else:
bot.send_message(recipient, adressee + random.choice(list(open('lists/polar_answers.txt'))))
bot.send_message(recipient, adressee + random.choice(list(open('lists/polar_answers.txt'))), nick)

def on_msg(self, bot, user_nick, host, channel, message):
self.answer(bot, message, channel, user_nick)

@@ -9,7 +9,7 @@ def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith(bot.translate("flatter_cmd")):
if len(message.split()) >= 2:
if bot.getlanguage() == "de":
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/flattery.txt'))))
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/flattery.txt'))), user_nick)
elif bot.getlanguage() == "en":
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/flattery_en.txt')))) # Source http://www.pickuplinesgalore.com/cheesy.html

# Source http://www.pickuplinesgalore.com/cheesy.html
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/flattery_en.txt'))), user_nick)
@@ -9,5 +9,5 @@ def on_msg(self, bot, user_nick, host, channel, message):
text = plugin.help_text(bot)
if text != "":
for t in text.split("\n"):
bot.send_message(user_nick, t)
bot.send_message(user_nick, t, user_nick)

@@ -9,6 +9,7 @@ def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith(bot.translate("insult_cmd")):
if len(message.split()) >= 2:
if bot.getlanguage() == "de":
bot.send_message(channel, message.split()[1] + ", du " + random.choice(list(open('lists/insults.txt'))))
bot.send_message(channel, message.split()[1] + ", du " + random.choice(list(open('lists/insults.txt'))), user_nick)
elif bot.getlanguage() == "en":
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/yomomma.txt')))) # source http://www.jokes4us.com/yomamajokes/yomamasofatjokes.html
# source http://www.jokes4us.com/yomamajokes/yomamasofatjokes.html
bot.send_message(channel, message.split()[1] + ", " + random.choice(list(open('lists/yomomma.txt'))), user_nick)
@@ -13,9 +13,9 @@ def on_msg(self, bot, user_nick, host, channel, message):
#msg = re.sub('https?://[^\s]+', '', msg)
if self.is_message_new(msg):
self.save_message(msg)
bot.send_message(channel, bot.translate("security_str1").format(msg=msg))
bot.send_message(channel, bot.translate("security_str1").format(msg=msg), user_nick)
if message.startswith("!security"):
bot.send_message(channel, bot.translate("security_str1").format(msg=msg))
bot.send_message(channel, bot.translate("security_str1").format(msg=msg), user_nick)

def save_message(self, msg):
f = open('/tmp/.internetbrenntcache','w')
@@ -8,6 +8,6 @@ def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!lang'):
if len(message.split()) >= 2:
if bot.setlanguage(message.split()[1]) == True:
bot.send_message(channel, bot.translate("language_str1"))
bot.send_message(channel, bot.translate("language_str1"), user_nick)
else:
bot.send_message(channel, bot.translate("language_str2"))
bot.send_message(channel, bot.translate("language_str2"), user_nick)
@@ -30,4 +30,4 @@ def get_light(self):
def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!licht'):
m = self.get_light()
bot.send_message(channel, 'Momentane Lichtverhaeltnisse: ' + m)
bot.send_message(channel, 'Momentane Lichtverhaeltnisse: ' + m, user_nick)
@@ -8,9 +8,9 @@ def help_text(self, bot):
def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!lineart'):
if len(message.split()) >= 1:
bot.send_message(channel, random.choice(list(open('lists/lineart.txt'))))
bot.send_message(channel, random.choice(list(open('lists/lineart.txt'))), user_nick)

def on_privmsg(self, bot, user_nick, host, message):
if message.lower().startswith('!lineart'):
if len(message.split()) >= 1:
bot.send_message(user_nick, random.choice(list(open('lists/lineart.txt'))))
bot.send_message(user_nick, random.choice(list(open('lists/lineart.txt'))), user_nick)
@@ -23,9 +23,9 @@ def on_msg(self, bot, user_nick, host, channel, message):
f = msg['online']

if int(f) > 0:
bot.send_message(channel, bot.translate("openstatus_str1").format(d=f))
bot.send_message(channel, bot.translate("openstatus_str1").format(d=f), user_nick)
else:
bot.send_message(channel, bot.translate("openstatus_str2").format(d=f))
bot.send_message(channel, bot.translate("openstatus_str2").format(d=f), user_nick)
else:
print "OpenStatus Error: [OpenStatus] url is not configured in your config.ini"

@@ -7,4 +7,4 @@ def help_text(self, bot):

def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!np'):
bot.send_message(channel, bot.translate("playlist_str1"))
bot.send_message(channel, bot.translate("playlist_str1"), user_nick)
@@ -35,4 +35,4 @@ def on_msg(self, bot, user_nick, host, channel, message):
else:
sentence = self.get_markov_sentence()

bot.send_message(channel, bot.sanitize(sentence))
bot.send_message(channel, bot.sanitize(sentence), user_nick)
@@ -25,4 +25,4 @@ def on_msg(self, bot, user_nick, host, channel, message):
msg = message.split()[1] + ", thou " + insult
else:
msg = 'Thou ' + insult
bot.send_message(channel, msg)
bot.send_message(channel, msg, user_nick)
@@ -31,6 +31,6 @@ def on_msg(self, bot, user_nick, host, channel, message):
if message.lower().startswith('!geraeusche') or message.lower().startswith('!sound'):
m = self.get_sound()
if not m == '':
bot.send_message(channel, 'Momentane Geraeuschintensitaet: ' + m + '/3300')
bot.send_message(channel, 'Momentane Geraeuschintensitaet: ' + m + '/3300', user_nick)
else:
bot.send_message(channel, 'Geraeuschintensitaet konnte *nicht* abgefragt werden')
bot.send_message(channel, 'Geraeuschintensitaet konnte *nicht* abgefragt werden', user_nick)
@@ -24,9 +24,9 @@ def tell(self, bot, user_nick, receiver, message):

if message.lower().startswith(bot.translate("tell_cmd")):
if (len(message.rstrip().split()) < 3) or (len(bot.split_by_nth(message.rstrip(), 2)[1]) <= 0):
bot.send_message(reply_to, user_nick + bot.translate("tell_str1"))
bot.send_message(reply_to, user_nick + bot.translate("tell_str1"), user_nick)
elif len(bot.split_by_nth(message, 2)[1]) > 144:
bot.send_message(reply_to, user_nick + bot.translate("tell_str2"))
bot.send_message(reply_to, user_nick + bot.translate("tell_str2"), user_nick)
else:
recipient = message.split()[1]
message = message.split(recipient)[1].strip()
@@ -46,13 +46,13 @@ def tell(self, bot, user_nick, receiver, message):
with open('tell_messages.json', 'w+') as outfile:
json.dump(self.messages, outfile)

bot.send_message(reply_to, bot.translate("tell_str3"))
bot.send_message(reply_to, bot.translate("tell_str3"), user_nick)

def on_join(self, bot, user_nick, host, channel):
user_messages = [message for message in self.messages if message["recipient"] == user_nick]
for message in user_messages:
if (not message["send_to"].startswith("#")) or (message["send_to"][1:] == channel):
bot.send_message(message["send_to"], user_nick + ", " + message["sender"] + " liess dir am " + message["date"] + " um " + message["time"] + " Uhr ausrichten: " + message["message"])
bot.send_message(message["send_to"], user_nick + ", " + message["sender"] + " liess dir am " + message["date"] + " um " + message["time"] + " Uhr ausrichten: " + message["message"], user_nick)
self.messages.remove(message)

with open('tell_messages.json', 'w+') as outfile:
@@ -37,16 +37,16 @@ def on_msg(self, bot, user_nick, host, channel, message):
temp_outdoor = self.get_outdoor_temp(bot)

if temp is not "":
bot.send_message(channel, bot.translate("temp_str1").format(temp=temp) + " " + bot.translate("temp_str2").format(temp=temp_outdoor))
bot.send_message(channel, bot.translate("temp_str1").format(temp=temp) + " " + bot.translate("temp_str2").format(temp=temp_outdoor), user_nick)
else:
bot.send_message(channel, bot.translate("temp_str3").format(temp=temp_outdoor))
bot.send_message(channel, bot.translate("temp_str3").format(temp=temp_outdoor), user_nick)

def on_privmsg(self, bot, user_nick, host, message):
if message.lower().startswith('!kt'):
temp = self.get_indoor_temp(bot)
temp_outdoor = self.get_outdoor_temp(bot)

if temp is not "":
bot.send_message(user_nick, bot.translate("temp_str1").format(temp=temp) + " " + bot.translate("temp_str2").format(temp=temp_outdoor))
bot.send_message(user_nick, bot.translate("temp_str1").format(temp=temp) + " " + bot.translate("temp_str2").format(temp=temp_outdoor), user_nick)
else:
bot.send_message(user_nick, bot.translate("temp_str3").format(temp=temp_outdoor))
bot.send_message(user_nick, bot.translate("temp_str3").format(temp=temp_outdoor), user_nick)
@@ -10,9 +10,9 @@ def on_msg(self, bot, user_nick, host, channel, message):
title = bot.sanitize(bot.geturltitle(url))
if not title == "":
if message.lower().startswith('!private') or message.lower().startswith('!pr'):
bot.send_message(channel, "[private] " + "Title: {title}".format(title=title))
bot.send_message(channel, "[private] " + "Title: {title}".format(title=title), user_nick)
elif message.lower().startswith('!nsfw'):
bot.send_message(channel, "[nsfw] " + "Title: {title}".format(title=title))
bot.send_message(channel, "[nsfw] " + "Title: {title}".format(title=title), user_nick)
else:
bot.send_message(channel, "Title: {title}".format(title=title))
bot.send_message(channel, "Title: {title}".format(title=title), user_nick)
print bot.get_plugin("MediaWiki").wikiupdate(title, url)
@@ -47,6 +47,11 @@ def __init__(self):
self.useragent=self.config.get('HTTP', 'useragent')
self.language=self.config.get('Language','language')

try:
self.ignore=self.config.get('IRC','ignore').split(',')
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
self.ignore = []

# load translation keys

# load optional config
@@ -122,8 +127,9 @@ def split_by_nth(self, text, n, seperator=' '):
res_l.extend(res_r)
return res_l

def send_message(self, recipient, msg):
self.irc.msg(recipient, "\x0F" + msg)
def send_message(self, recipient, msg, srcuser=''):
if srcuser not in self.ignore:
self.irc.msg(recipient, "\x0F" + msg)

def send_command(self, recipient, cmd):
self.irc.msg(recipient, cmd)

0 comments on commit 2aab389

Please sign in to comment.
You can’t perform that action at this time.