Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
errbot-karma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRC Team
Errbot Development
errbot-karma
Commits
896d248c
Commit
896d248c
authored
7 years ago
by
Bruce Cowan
Browse files
Options
Downloads
Patches
Plain Diff
Reduce duplication
Subtraction is just adding a negative value
parent
36ff6dfc
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
karma.py
+6
-11
6 additions, 11 deletions
karma.py
with
6 additions
and
11 deletions
karma.py
+
6
−
11
View file @
896d248c
...
...
@@ -35,13 +35,8 @@ class Karma(BotPlugin):
super
().
deactivate
()
def
_inc_karma
(
self
,
target
,
message
):
self
.
karma
[
target
]
+=
1
text
=
"
Karma for
'
{}
'
is now {}
"
.
format
(
target
,
self
.
karma
[
target
])
self
.
send
(
message
.
to
,
text
,
message
,
True
)
def
_dec_karma
(
self
,
target
,
message
):
self
.
karma
[
target
]
-=
1
def
_change_karma
(
self
,
target
,
value
,
message
):
self
.
karma
[
target
]
+=
value
text
=
"
Karma for
'
{}
'
is now {}
"
.
format
(
target
,
self
.
karma
[
target
])
self
.
send
(
message
.
to
,
text
,
message
,
True
)
...
...
@@ -49,12 +44,12 @@ class Karma(BotPlugin):
# Increment?
match
=
self
.
inc
.
search
(
message
.
body
)
if
match
:
self
.
_
inc
_karma
(
match
.
group
(
1
),
message
)
self
.
_
change
_karma
(
match
.
group
(
1
),
1
,
message
)
# Decrement?
match
=
self
.
dec
.
search
(
message
.
body
)
if
match
:
self
.
_
dec
_karma
(
match
.
group
(
1
),
message
)
self
.
_
change
_karma
(
match
.
group
(
1
),
-
1
,
message
)
@botcmd
def
karma_list
(
self
,
message
,
args
):
...
...
@@ -71,7 +66,7 @@ class Karma(BotPlugin):
if
not
args
:
return
"
**Usage**: !karma add <target>
"
self
.
_
inc
_karma
(
args
,
message
)
self
.
_
change
_karma
(
args
,
1
,
message
)
@botcmd
def
karma_remove
(
self
,
message
,
args
):
...
...
@@ -79,7 +74,7 @@ class Karma(BotPlugin):
if
not
args
:
return
"
**Usage**: !karma remove <target>
"
self
.
_
dec
_karma
(
args
,
message
)
self
.
_
change
_karma
(
args
,
-
1
,
message
)
@botcmd
def
karma
(
self
,
message
,
args
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment