Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
98
Issues
98
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
a0755178
Commit
a0755178
authored
Dec 27, 2013
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Basic isupport support
CHANMODES and PREFIX only
parent
43cc60e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+28
-1
src/irc/irc_client.hpp
src/irc/irc_client.hpp
+21
-0
No files found.
src/irc/irc_client.cpp
View file @
a0755178
...
...
@@ -16,7 +16,8 @@ IrcClient::IrcClient(const std::string& hostname, const std::string& username, B
username
(
username
),
current_nick
(
username
),
bridge
(
bridge
),
welcomed
(
false
)
welcomed
(
false
),
chanmodes
({
""
,
""
,
""
,
""
})
{
}
...
...
@@ -196,6 +197,32 @@ void IrcClient::forward_server_message(const IrcMessage& message)
this
->
bridge
->
send_xmpp_message
(
this
->
hostname
,
from
,
body
);
}
void
IrcClient
::
on_isupport_message
(
const
IrcMessage
&
message
)
{
const
size_t
len
=
message
.
arguments
.
size
();
for
(
size_t
i
=
1
;
i
<
len
;
++
i
)
{
const
std
::
string
token
=
message
.
arguments
[
i
];
if
(
token
.
substr
(
0
,
10
)
==
"CHANMODES="
)
{
this
->
chanmodes
=
utils
::
split
(
token
.
substr
(
11
),
','
);
// make sure we have 4 strings
this
->
chanmodes
.
resize
(
4
);
}
else
if
(
token
.
substr
(
0
,
7
)
==
"PREFIX="
)
{
size_t
i
=
8
;
// jump PREFIX=(
size_t
j
=
9
;
// Find the ) char
while
(
j
<
token
.
size
()
&&
token
[
j
]
!=
')'
)
j
++
;
j
++
;
while
(
j
<
token
.
size
()
&&
token
[
i
]
!=
')'
)
this
->
prefix_to_mode
[
token
[
j
++
]]
=
token
[
i
++
];
}
}
}
void
IrcClient
::
send_gateway_message
(
const
std
::
string
&
message
,
const
std
::
string
&
from
)
{
this
->
bridge
->
send_xmpp_message
(
this
->
hostname
,
from
,
message
);
...
...
src/irc/irc_client.hpp
View file @
a0755178
...
...
@@ -8,7 +8,9 @@
#include <network/socket_handler.hpp>
#include <unordered_map>
#include <vector>
#include <string>
#include <map>
class
Bridge
;
...
...
@@ -109,6 +111,11 @@ public:
* Forward the server message received from IRC to the XMPP component
*/
void
forward_server_message
(
const
IrcMessage
&
message
);
/**
* When receiving the isupport informations. See
* http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
*/
void
on_isupport_message
(
const
IrcMessage
&
message
);
/**
* Just empty the motd we kept as a string
*/
...
...
@@ -208,11 +215,24 @@ private:
*/
std
::
vector
<
std
::
string
>
channels_to_join
;
bool
welcomed
;
/**
* See http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt section 3.3
* We store the possible chanmodes in this object.
* chanmodes[0] contains modes of type A, [1] of type B etc
*/
std
::
vector
<
std
::
string
>
chanmodes
;
/**
* Each motd line received is appended to this string, which we send when
* the motd is completely received
*/
std
::
string
motd
;
/**
* See http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt section 3.14
* The example given would be transformed into
* modes_to_prefix = {{'a', '&'}, {'b', '*'}}
*/
std
::
map
<
char
,
char
>
prefix_to_mode
;
IrcClient
(
const
IrcClient
&
)
=
delete
;
IrcClient
(
IrcClient
&&
)
=
delete
;
IrcClient
&
operator
=
(
const
IrcClient
&
)
=
delete
;
...
...
@@ -229,6 +249,7 @@ static const std::unordered_map<std::string, irc_callback_t> irc_callbacks = {
{
"NOTICE"
,
&
IrcClient
::
forward_server_message
},
{
"002"
,
&
IrcClient
::
forward_server_message
},
{
"003"
,
&
IrcClient
::
forward_server_message
},
{
"005"
,
&
IrcClient
::
on_isupport_message
},
{
"RPL_MOTDSTART"
,
&
IrcClient
::
empty_motd
},
{
"375"
,
&
IrcClient
::
empty_motd
},
{
"RPL_MOTD"
,
&
IrcClient
::
on_motd_line
},
...
...
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