Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gajim-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
gajim
gajim-plugins
Merge requests
!221
New plugin: Ascii Emoji
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
New plugin: Ascii Emoji
principis/gajim-plugins:ascii-emoji
into
master
Overview
1
Commits
1
Pipelines
5
Changes
6
Open
Arthur Bols
requested to merge
principis/gajim-plugins:ascii-emoji
into
master
2 years ago
Overview
1
Commits
1
Pipelines
5
Changes
3
Expand
Adds the old ascii->emoji conversion with a plugin!
Edited
2 years ago
by
Arthur Bols
0
0
Merge request reports
Compare
version 3
version 5
3d8a6a77
2 years ago
version 4
152502f9
2 years ago
version 3
4b9ee331
2 years ago
version 2
8aed2177
2 years ago
version 1
de4aa02e
2 years ago
master (HEAD)
and
version 4
latest version
3d8a6a77
1 commit,
1 month ago
version 5
3d8a6a77
1 commit,
2 years ago
version 4
152502f9
1 commit,
2 years ago
version 3
4b9ee331
1 commit,
2 years ago
version 2
8aed2177
1 commit,
2 years ago
version 1
de4aa02e
1 commit,
2 years ago
Show latest version
3 files
+
169
−
59
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
ascii_emoji/modules/ascii_emoji.py
0 → 100644
+
71
−
0
Options
# Copyright (C) 2022 Arthur Bols <arthur@bols.dev>
#
# This file is part of Ascii Emoji Gajim Plugin.
#
# Ascii Emoji Gajim Plugin is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Ascii Emoji Gajim Plugin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ascii Emoji Gajim Plugin. If not, see <http://www.gnu.org/licenses/>.
import
re
import
logging
from
nbxmpp.structs
import
StanzaHandler
from
gajim.common
import
ged
from
gajim.common.modules.base
import
BaseModule
from
ascii_emoji.modules.data
import
emoji_map
log
=
logging
.
getLogger
(
'
gajim.p.ascii_emoji
'
)
# Module name
name
=
'
AsciiEmoji
'
class
AsciiEmoji
(
BaseModule
):
def
__init__
(
self
,
con
):
BaseModule
.
__init__
(
self
,
con
,
plugin
=
True
)
self
.
handlers
=
[
StanzaHandler
(
name
=
'
message
'
,
callback
=
self
.
_on_message_received
,
priority
=
ged
.
PREGUI
),
]
self
.
emoticon_regex
=
re
.
compile
(
emoji_map
.
get_regex
())
def
replace
(
self
,
msg
):
iterator
=
self
.
emoticon_regex
.
finditer
(
msg
)
new_msgtxt
=
''
prev_repl
=
0
for
match
in
iterator
:
start
,
end
=
match
.
span
()
ascii_text
=
msg
[
start
:
end
]
emoji
=
emoji_map
.
get
(
ascii_text
,
None
)
if
emoji
is
not
None
:
new_msgtxt
+=
msg
[
prev_repl
:
start
]
+
emoji
prev_repl
=
end
return
new_msgtxt
+
msg
[
prev_repl
:]
def
_on_message_received
(
self
,
_con
,
_stanza
,
properties
):
if
not
properties
.
body
:
log
.
debug
(
"
Received message does not have a body
"
)
return
properties
.
body
=
self
.
replace
(
properties
.
body
)
def
get_instance
(
*
args
,
**
kwargs
):
return
AsciiEmoji
(
*
args
,
**
kwargs
),
'
AsciiEmoji
'
Loading