Skip to content

Commit

Permalink
Moderation && Base Maj
Browse files Browse the repository at this point in the history
  • Loading branch information
Ne02ptzero committed Nov 18, 2014
1 parent 5557855 commit e42d8b7
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 76 deletions.
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"host": "irc.freenode.net",
"chan": "#ne02ptzero",
"chan": "#morphux",
"port": "6667",
"symbol": "!",
"nick": "Bot2fab4u",
"password": "",
"nick": "CL4P_TP",
"password": "morphuxftw",
"debug": 1,
"identify": 0,
"identify": 1,
"welcomeMessage": "o/",
"errorMessage": "Duknow this command !"
}
1 change: 1 addition & 0 deletions core/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def kick(self, user, message = ""):
if (message == ""):
message = self.config["banMessage"]
self.coreSend("KICK " + self.config["chan"] + " " + user + " : " + message)
print "HERE KICK"

# Join a channel
def join(self):
Expand Down
File renamed without changes.
25 changes: 25 additions & 0 deletions modules/base/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Base Module
# By: Louis <louis@ne02ptzero>

class Base:

def command(self):
self.config = {
"command": {
"ping": {
"function": self.ping,
"usage": "ping",
"help": "Make a ping to the bot"
}
},
"onJoin": {
"join": self.join
}
}
return self.config

def ping(self, Morphux, infos):
Morphux.sendMessage("Pong !", infos['nick'])

def join(self, Morphux, user):
Morphux.sendMessage("Hey, howr u doin :) ?", user)
66 changes: 0 additions & 66 deletions modules/hi/hi.py

This file was deleted.

Empty file added modules/moderate/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions modules/moderate/moderate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Moderation Module
# By: Louis <[email protected]>

class Moderate:
def command(self):
self.config = {
"command": {
"kick": {
"function": self.kick,
"usage": "kick user",
"help": "GET REKT"
}
}
}
return self.config

def kick(self, Morphux, infos):
if (Morphux.isAdmin(infos['nick'])):
if (len(infos['args'])):
Morphux.kick(infos['args'][0], "GET REKT")
else:
Morphux.sendMessage("You're not admin !", infos['nick'])
18 changes: 12 additions & 6 deletions morphux.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def loop(self):
elif (infos != False):
if (infos["command"] in self.commands):
self.commands[infos["command"]]["function"](self, infos)
print("New command:" + infos["command"])
print("New command ["+ infos['nick'] +"]: " + infos["command"])
else:
self.sendMessage(self.config["errorMessage"], infos["nick"])
for name, function in self.after.items():
Expand Down Expand Up @@ -150,6 +150,8 @@ def onJoin(self, line):
user = line.split(" ")
user[0] = user[0][1:]
self.currentUsers[user[0].split("!")[0]] = True
if (user[0].split("!")[0] == self.config['nick']):
return
for name, function in self.join.items():
function(self, user[0].split("!")[0])

Expand All @@ -163,6 +165,8 @@ def onNickChange(self, line):
if (userName[0] in self.currentUsers):
del self.currentUsers[userName[0]]
self.currentUsers[newNick] = True
if (newNick == self.config['nick']):
return
for name, function in self.nickChange.items():
function(self, userName[0], newNick)

Expand All @@ -173,10 +177,8 @@ def getHeadersLine(self, line):
line = line.split("\n")
for value in line:
users = value.split(":")
# :barjavel.freenode.net 353 Bot2fab4u = #morphux :Bot2fab4u abclive ryad Enerdhil[Phone] Valouche Noich @Ne02ptzero enerdhil @CL4P_TP Noich_root
if (len(users) >= 2):
details = users[1].split(" ")
#print value
if (len(details) >= 2):
if (details[1] == "353"):
users = users[2].split(" ")
Expand Down Expand Up @@ -220,9 +222,9 @@ def userExists(self, nick):
# If User is Admin
# @param: string
def isAdmin(self, nick):
if (userExists(nick)):
if ('isAdmin' in self.currentUsers[nick]):
if (self.currentUsers[nick] == 1):
if (self.userExists(nick)):
if (self.currentUsers[nick] != True):
if ('isAdmin' in self.currentUsers[nick]):
return True
return False

Expand All @@ -235,3 +237,7 @@ def showHelp(self, args):
self.sendMessage(args[0] +": <"+ usage +"> ("+help+")")
else:
self.sendMessage("Can't find command " + args[0])

# Kick an user
def kick(self, user, reason):
self.s.kick(user, reason)

0 comments on commit e42d8b7

Please sign in to comment.