Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
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
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
John Smith
gajim
Commits
b1675bf2
Commit
b1675bf2
authored
14 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
rename variables in plugins. Fixes #5994
parent
278ba237
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/google_translation/plugin.py
+3
-3
3 additions, 3 deletions
plugins/google_translation/plugin.py
plugins/new_events_example/plugin.py
+27
-30
27 additions, 30 deletions
plugins/new_events_example/plugin.py
with
30 additions
and
33 deletions
plugins/google_translation/plugin.py
+
3
−
3
View file @
b1675bf2
...
...
@@ -104,13 +104,13 @@ class GoogleTranslateMessageReceivedEvent(nec.NetworkIncomingEvent):
base_network_events
=
[
'
raw-message-received
'
]
def
generate
(
self
):
msg_type
=
self
.
base_event
.
xmpp_msg
.
attrs
.
get
(
'
type
'
,
None
)
msg_type
=
self
.
base_event
.
stanza
.
attrs
.
get
(
'
type
'
,
None
)
if
msg_type
==
u
'
chat
'
:
msg_text
=
""
.
join
(
self
.
base_event
.
xmpp_msg
.
kids
[
0
].
data
)
msg_text
=
""
.
join
(
self
.
base_event
.
stanza
.
kids
[
0
].
data
)
if
msg_text
:
from_lang
=
self
.
plugin
.
config
[
'
from_lang
'
]
to_lang
=
self
.
plugin
.
config
[
'
to_lang
'
]
self
.
base_event
.
xmpp_msg
.
kids
[
0
].
setData
(
self
.
base_event
.
stanza
.
kids
[
0
].
setData
(
self
.
plugin
.
translate_text
(
msg_text
,
from_lang
,
to_lang
))
# We only want to modify old event, not emit another, so we return False
...
...
This diff is collapsed.
Click to expand it.
plugins/new_events_example/plugin.py
+
27
−
30
View file @
b1675bf2
...
...
@@ -46,34 +46,31 @@ class NewEventsExamplePlugin(GajimPlugin):
#self.config_default_values = {}
self
.
events_handlers
=
{
'
raw-message-received
'
:
(
ged
.
POSTCORE
,
self
.
raw_message_received
),
'
customized-message-received
'
:
(
ged
.
POSTCORE
,
self
.
customized_message_received
),
'
enriched-chat-message-received
'
:
(
ged
.
POSTCORE
,
self
.
enriched_chat_message_received
)}
(
ged
.
POSTCORE
,
self
.
raw_message_received
),
'
customized-message-received
'
:
(
ged
.
POSTCORE
,
self
.
customized_message_received
),
'
enriched-chat-message-received
'
:
(
ged
.
POSTCORE
,
self
.
enriched_chat_message_received
)}
self
.
events
=
[
CustomizedMessageReceivedEvent
,
MoreCustomizedMessageReceivedEvent
,
ModifyOnlyMessageReceivedEvent
,
EnrichedChatMessageReceivedEvent
]
MoreCustomizedMessageReceivedEvent
,
ModifyOnlyMessageReceivedEvent
,
EnrichedChatMessageReceivedEvent
]
def
enriched_chat_message_received
(
self
,
event_object
):
pass
#print "Event '%s' occured. Event object: %s\n\n===\n"
%(event_object.name,
#
event_object)
#
print "Event '%s' occured. Event object: %s\n\n===\n"
% \
# (event_object.name,
event_object)
def
raw_message_received
(
self
,
event_object
):
pass
#print "Event '%s' occured. Event object: %s\n\n===\n"
%(event_object.name,
#
event_object)
#
print "Event '%s' occured. Event object: %s\n\n===\n"
% \
# (event_object.name,
event_object)
def
customized_message_received
(
self
,
event_object
):
pass
#print "Event '%s' occured. Event object: %s\n\n===\n"
%(event_object.name,
#
event_object
#
print "Event '%s' occured. Event object: %s\n\n===\n"
% \
# (event_object.name,
event_object
@log_calls
(
'
NewEventsExamplePlugin
'
)
def
activate
(
self
):
...
...
@@ -107,11 +104,11 @@ class ModifyOnlyMessageReceivedEvent(nec.NetworkIncomingEvent):
base_network_events
=
[
'
raw-message-received
'
]
def
generate
(
self
):
msg_type
=
self
.
base_event
.
xmpp_msg
.
attrs
.
get
(
'
type
'
,
None
)
msg_type
=
self
.
base_event
.
stanza
.
attrs
.
get
(
'
type
'
,
None
)
if
msg_type
==
u
'
chat
'
:
msg_text
=
""
.
join
(
self
.
base_event
.
xmpp_msg
.
kids
[
0
].
data
)
self
.
base_event
.
xmpp_msg
.
kids
[
0
].
setData
(
u
'
%s [MODIFIED BY CUSTOM NETWORK EVENT]
'
%
(
msg_text
))
msg_text
=
''
.
join
(
self
.
base_event
.
stanza
.
kids
[
0
].
data
)
self
.
base_event
.
stanza
.
kids
[
0
].
setData
(
u
'
%s [MODIFIED BY CUSTOM NETWORK EVENT]
'
%
(
msg_text
))
return
False
...
...
@@ -124,17 +121,17 @@ class EnrichedChatMessageReceivedEvent(nec.NetworkIncomingEvent):
base_network_events
=
[
'
raw-message-received
'
]
def
generate
(
self
):
msg_type
=
self
.
base_event
.
xmpp_msg
.
attrs
.
get
(
'
type
'
,
None
)
msg_type
=
self
.
base_event
.
stanza
.
attrs
.
get
(
'
type
'
,
None
)
if
msg_type
==
u
'
chat
'
:
self
.
xmpp_msg
=
self
.
base_event
.
xmpp_msg
self
.
stanza
=
self
.
base_event
.
stanza
self
.
conn
=
self
.
base_event
.
conn
self
.
from_jid
=
helpers
.
get_full_jid_from_iq
(
self
.
xmpp_msg
)
self
.
from_jid_without_resource
=
gajim
.
get_jid_without_resource
(
self
.
from_jid
)
self
.
account
=
self
.
base_event
.
account
self
.
from_nickname
=
gajim
.
get_contact_name_from_jid
(
self
.
account
,
self
.
from_jid_without_resource
)
self
.
msg_text
=
""
.
join
(
self
.
xmpp_msg
.
kids
[
0
].
data
)
self
.
from_jid
=
helpers
.
get_full_jid_from_iq
(
self
.
stanza
)
self
.
from_jid_without_resource
=
gajim
.
get_jid_without_resource
(
self
.
from_jid
)
self
.
account
=
self
.
conn
.
name
self
.
from_nickname
=
gajim
.
get_contact_name_from_jid
(
self
.
account
,
self
.
from_jid_without_resource
)
self
.
msg_text
=
''
.
join
(
self
.
stanza
.
kids
[
0
].
data
)
return
True
...
...
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