Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
NinjaBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Benjamin Graillot
NinjaBot
Commits
ee385852
Commit
ee385852
authored
Apr 06, 2018
by
Maxime Bombar
1
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.crans.org:esum/NinjaBot
parents
1bc199bb
b9963534
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
173 additions
and
77 deletions
+173
-77
src/bot.py
src/bot.py
+45
-0
src/nsabot.py
src/nsabot.py
+128
-77
No files found.
src/bot.py
0 → 100644
View file @
ee385852
import
irc.bot
import
config
class
Bot
(
irc
.
bot
.
SingleServerIRCBot
):
def
__init__
(
self
,
nickname
,
channel
=
"#bot"
,
server
=
"irc.crans.org"
,
port
=
6667
):
irc
.
bot
.
SingleServerIRCBot
.
__init__
(
self
,
[(
server
,
port
)],
nickname
,
nickname
)
self
.
nick
=
nickname
self
.
channel
=
channel
self
.
operators
=
config
.
operators
def
on_nicknameinuse
(
self
,
conn
,
e
):
conn
.
nick
(
conn
.
get_nickname
()
+
"_"
)
self
.
nick
+=
"_"
def
on_welcome
(
self
,
conn
,
e
):
conn
.
join
(
self
.
channel
)
self
.
on_welcome_ext
(
conn
,
e
)
def
on_privmsg
(
self
,
conn
,
e
):
if
e
.
source
.
nick
in
self
.
operators
:
return
self
.
do_command
(
conn
,
e
.
arguments
[
0
]
.
split
(
' '
),
self
.
operators
[
e
.
source
.
nick
],
e
.
source
.
nick
)
return
self
.
do_command
(
conn
,
e
.
arguments
[
0
]
.
split
(
' '
),
0
,
e
.
source
.
nick
)
def
do_command
(
self
,
conn
,
command
,
level
,
source
):
if
command
[
0
]
.
casefold
()
==
"op"
:
if
len
(
command
)
==
2
:
dst_level
=
100
else
:
try
:
dst_level
=
int
(
command
[
2
])
except
:
dst_level
=
0
if
0
<=
dst_level
<
level
:
self
.
operators
[
command
[
1
]]
=
dst_level
elif
command
[
0
]
.
casefold
()
==
"join"
and
level
>=
100
:
for
channel
in
command
[
1
:]:
conn
.
join
(
channel
)
elif
command
[
0
]
.
casefold
()
==
"leave"
and
level
>=
100
:
for
channel
in
command
[
1
:]:
conn
.
part
(
channel
,
"Ce n'est qu'un au revoir"
)
else
:
self
.
do_command_ext
(
conn
,
command
,
level
,
source
)
src/nsabot.py
View file @
ee385852
This diff is collapsed.
Click to expand it.
Maxime Bombar
@bombar
mentioned in commit
01f0447c
·
Apr 06, 2018
mentioned in commit
01f0447c
mentioned in commit 01f0447c1437ddbb360b6442f557857e1c3a728b
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment