forked from wolfc/userserv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
userserv.c
112 lines (85 loc) · 2.26 KB
/
userserv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <string.h>
#include <debug.h>
#include <plugin.h>
#include <prpl.h>
#include <version.h>
#define PLUGIN_ID "userserv"
#define VERSION "0.1"
static PurplePluginProtocolInfo *irc_info = NULL;
static void
signed_on(PurpleConnection *connection)
{
PurpleAccount *account;
const char *username;
const char *password;
gchar **usernameTokens;
gchar *msg;
account = purple_connection_get_account(connection);
if(strcmp("prpl-irc", purple_account_get_protocol_id(account)))
return;
password = purple_account_get_password(account);
if(password == NULL)
return;
username = purple_account_get_username(account);
usernameTokens = g_strsplit(username, "@", 2);
if(!strcmp("irc.devel.redhat.com", usernameTokens[1]))
{
msg = g_strdup_printf("PRIVMSG USERSERV :login %s %s\r\n", usernameTokens[0], password);
purple_debug_info("userserv", "sending %s\n", msg);
irc_info->send_raw(connection, msg, strlen(msg));
g_free(msg);
}
g_strfreev(usernameTokens);
}
static gboolean
plugin_load(PurplePlugin *plugin)
{
PurplePlugin *prpl;
void *gc_handle;
prpl = purple_find_prpl("prpl-irc");
if(!prpl)
return FALSE;
irc_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
gc_handle = purple_connections_get_handle();
purple_signal_connect(gc_handle, "signed-on", plugin,
G_CALLBACK(signed_on), NULL);
return TRUE;
}
static gboolean
plugin_unload(PurplePlugin *plugin)
{
return TRUE;
}
static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
PURPLE_MINOR_VERSION,
PURPLE_PLUGIN_STANDARD,
NULL, // ui_requirement
0, // flags
NULL, // dependencies
PURPLE_PRIORITY_DEFAULT,
PLUGIN_ID,
"userserv", // name
VERSION,
"Makes you logon using userserv.", // summary
"description",
"Carlo de Wolf <[email protected]>",
NULL, // homepage
plugin_load,
plugin_unload,
NULL, // destroy
NULL, // ui_info
NULL, // extra_info
NULL, // prefs_info
NULL, // actions
NULL, // reserved1
NULL, // reserved2
NULL, // reserved3
NULL // reserved4
};
static void
init_plugin(PurplePlugin *plugin)
{
}
PURPLE_INIT_PLUGIN(userserv, init_plugin, info)