[ekg2-commit] r3790 - trunk/plugins/polchat: trunk/plugins/polchat/polchat.c trunk/plugins/polchat/polchat_handlers.c
SVN commit
svn w toxygen.net
Sob, 16 Lut 2008, 00:06:45 CET
Author: darkjames
Date: 2008-02-16 00:06:44 +0100 (Sat, 16 Feb 2008)
New Revision: 3790
Modified:
trunk/plugins/polchat/polchat.c
trunk/plugins/polchat/polchat_handlers.c
Log:
- fix /part reason
- fix /join
- implement private message. (incoming / outgoing)
- implement some commands.
Modified: trunk/plugins/polchat/polchat.c
===================================================================
--- trunk/plugins/polchat/polchat.c 2008-02-15 23:04:26 UTC (rev 3789)
+++ trunk/plugins/polchat/polchat.c 2008-02-15 23:06:44 UTC (rev 3790)
@@ -50,10 +50,17 @@
#include <ekg/queries.h>
+#define DEFPARTMSG "EKG2 bejbi! http://ekg2.org/"
#define DEFQUITMSG "EKG2 - It's better than sex!"
+
+#define SGPARTMSG(x) session_get(x, "PART_MSG")
#define SGQUITMSG(x) session_get(x, "QUIT_MSG")
+
+#define PARTMSG(x,r) (r?r: SGPARTMSG(x)?SGPARTMSG(x):DEFPARTMSG)
#define QUITMSG(x) (SGQUITMSG(x)?SGQUITMSG(x):DEFQUITMSG)
+#define DEFPART
+
typedef struct {
int fd;
int connecting;
@@ -592,12 +599,27 @@
}
static COMMAND(polchat_command_msg) {
- /* w target -> target */
+ polchat_private_t *j = session->priv;
+
/* NOTE: sending `/quit` msg disconnect session */ /* XXX, escape? */
-/* polchat_sendpkt(session, 0x019a, params[1], NULL); */
- polchat_sendmsg(session, "%s", params[1]);
+ if (!xstrncmp(target, "polchat:", 8))
+ target += 8;
+ if (j->room && !xstrcmp(target, j->room+8)) {
+ /* polchat_sendpkt(session, 0x019a, params[1], NULL); */
+ polchat_sendmsg(session, "%s", params[1]);
+ } else {
+#if 0 /* nie musimy tego sprawdzac, serwer za nas to robi */
+ if (!(userlist_find(session, target))) {
+ debug_error("polchat_command_msg() but target: %s not found in userlist, neither eq j->room: %s\n", target, j->room);
+ printq("generic_error", "see debug");
+ return 0;
+ }
+#endif
+ polchat_sendmsg(session, "/msg %s %s", target, params[1]);
+ }
+
return 0;
}
@@ -615,13 +637,14 @@
static COMMAND(polchat_command_part) {
polchat_private_t *j = session->priv;
+ const char *reason = PARTMSG(session, params[0]);
if (!j->room) {
printq("invalid_params", name);
return 0;
}
- polchat_sendmsg(session, "/part");
+ polchat_sendmsg(session, "/part %s", reason);
return 0;
}
@@ -629,6 +652,15 @@
static COMMAND(polchat_command_join) {
polchat_private_t *j = session->priv;
+ if (!xstrncmp(target, "polchat:", 8))
+ target += 8;
+
+ if (j->room && !xstrcmp(j->room + 8, target)) {
+ /* ten sam pokoj, ignoruj */
+ printq("generic", "Jestes wlasnie w tym pokoju"); /* XXX */
+ return 0;
+ }
+
if (j->newroom) {
debug_error("/join but j->newroom: %s\n", j->newroom);
@@ -636,13 +668,22 @@
return 0;
}
- polchat_sendmsg(session, "/join %s", params[0]);
+ polchat_sendmsg(session, "/join %s", target);
- j->newroom = saprintf("polchat:%s", params[0]);
+ j->newroom = saprintf("polchat:%s", target);
return 0;
}
+static COMMAND(polchat_command_raw) {
+ if (params[0])
+ polchat_sendmsg(session, "/%s %s", name, params[0]);
+ else
+ polchat_sendmsg(session, "/%s", name);
+
+ return 0;
+}
+
static int polchat_theme_init() {
#ifndef NO_DEFAULT_THEME
/*
@@ -694,6 +735,21 @@
command_add(&polchat_plugin, "polchat:part", "r", polchat_command_part, POLCHAT_ONLY, NULL);
command_add(&polchat_plugin, "polchat:join", "!uUw", polchat_command_join, POLCHAT_FLAGS_TARGET, NULL);
+/* XXX, REQ params ? */
+ command_add(&polchat_plugin, "polchat:info", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:op", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:unop", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:halfop", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:tmphalfop", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+
+ /* /guest /unguest */
+ /* /buddy /unbuddy /ignore /unignore */
+
+ command_add(&polchat_plugin, "polchat:kick", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:ban", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:banip", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+ command_add(&polchat_plugin, "polchat:unban", "?", polchat_command_raw, POLCHAT_ONLY, NULL);
+
return 0;
}
Modified: trunk/plugins/polchat/polchat_handlers.c
===================================================================
--- trunk/plugins/polchat/polchat_handlers.c 2008-02-15 23:04:26 UTC (rev 3789)
+++ trunk/plugins/polchat/polchat_handlers.c 2008-02-15 23:06:44 UTC (rev 3790)
@@ -189,6 +189,7 @@
char *tmp = html_to_ekg2(strings[0]);
char *tmp2= format_string(tmp);
+/* XXX, wysylac przez PROTOCOL-MESSAGE */
print_window(j->room, s, 1, "none", tmp2);
xfree(tmp2);
@@ -200,11 +201,37 @@
}
POLCHAT_HANDLER(polchat_privmsg) {
- if (nheaders == 1 && nstrings == 2) {
- debug("polchat_processpkt() HEADER0_PRIVMSG INC(?) : NICK: %s MSG: %s\n", strings[1], strings[0]);
+ if (nheaders == 1 && nstrings == 2) { /* wiadomosc ktora ktos nam wyslal */
+ char *tmp = html_to_ekg2(strings[0]);
+ char *tmp2= format_string(tmp);
+
+ char *uid = saprintf("polchat:%s", strings[1]);
+
+/* XXX, wysylac przez PROTOCOL-MESSAGE */
+ print_window(uid, s, 1, "none", tmp2);
+
+ xfree(uid);
+
+ xfree(tmp2);
+ xfree(tmp);
+
return 0;
- } else if (nheaders == 1 && nstrings == 3) {
- debug("polchat_processpkt() HEADER0_PRIVMSG OUT(?) : UNK[0]: %s\nUNK[1]: %s\nMSG: %s\n", strings[0], strings[1], strings[2]);
+ } else if (nheaders == 1 && nstrings == 3) { /* wiadomosc ktora wyslalismy */
+ char *tmp = html_to_ekg2(strings[0]);
+ char *tmp2= format_string(tmp);
+
+ char *uid = saprintf("polchat:%s", strings[2]);
+
+/* XXX, wysylac przez PROTOCOL-MESSAGE */
+ print_window(uid, s, 1, "none", tmp2);
+
+ /* mozemy sprawdzic czy strings[1] == my */
+
+ xfree(uid);
+
+ xfree(tmp2);
+ xfree(tmp);
+
return 0;
}
Więcej informacji o liście dyskusyjnej ekg2-commit