Changeset 50e1776


Ignore:
Timestamp:
2007-11-19T22:23:58Z (16 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
ef5c185
Parents:
ebb95b6
Message:

Merging /TOPIC code from Miklos Vajna. Untested, because I still have to
implement the Jabber hooks.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • irc.c

    rebb95b6 r50e1776  
    788788void irc_topic( irc_t *irc, char *channel )
    789789{
    790         if( g_strcasecmp( channel, irc->channel ) == 0 )
    791         {
     790        struct groupchat *c = irc_chat_by_channel( irc, channel );
     791       
     792        if( c && c->topic )
     793                irc_reply( irc, 332, "%s :%s", channel, c->topic );
     794        else if( g_strcasecmp( channel, irc->channel ) == 0 )
    792795                irc_reply( irc, 332, "%s :%s", channel, CONTROL_TOPIC );
    793         }
    794796        else
    795         {
    796                 struct groupchat *c = irc_chat_by_channel( irc, channel );
    797                
    798                 if( c )
    799                         irc_reply( irc, 332, "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", channel, c->title );
    800                 else
    801                         irc_reply( irc, 331, "%s :No topic for this channel", channel );
    802         }
     797                irc_reply( irc, 331, "%s :No topic for this channel", channel );
    803798}
    804799
  • irc_commands.c

    rebb95b6 r50e1776  
    421421static void irc_cmd_topic( irc_t *irc, char **cmd )
    422422{
    423         if( cmd[2] )
    424                 irc_reply( irc, 482, "%s :Cannot change topic", cmd[1] );
    425         else
    426                 irc_topic( irc, cmd[1] );
     423        char *channel = cmd[1];
     424        char *topic = cmd[2];
     425       
     426        if( topic )
     427        {
     428                /* Send the topic */
     429                struct groupchat *c = irc_chat_by_channel( irc, channel );
     430                if( c && c->ic && c->ic->acc->prpl->chat_topic )
     431                        c->ic->acc->prpl->chat_topic( c, topic );
     432        }
     433        else
     434        {
     435                /* Get the topic */
     436                irc_topic( irc, channel );
     437        }
    427438}
    428439
  • protocols/nogaim.c

    rebb95b6 r50e1776  
    760760}
    761761
     762void imcb_chat_topic( struct groupchat *c, char *who, char *topic )
     763{
     764        struct im_connection *ic = c->ic;
     765        user_t *u = NULL;
     766       
     767        if( who == NULL)
     768                u = user_find( ic, ic->irc->mynick );
     769        else if( g_strcasecmp( who, ic->acc->user ) == 0 )
     770                u = user_find( ic, ic->irc->nick );
     771        else
     772                u = user_findhandle( ic, who );
     773       
     774        if( ( g_strcasecmp( set_getstr( &ic->irc->set, "strip_html" ), "always" ) == 0 ) ||
     775            ( ( ic->flags & OPT_DOES_HTML ) && set_getbool( &ic->irc->set, "strip_html" ) ) )
     776                strip_html( topic );
     777       
     778        g_free( c->topic );
     779        c->topic = g_strdup( topic );
     780       
     781        if( c->joined && u )
     782                irc_write( ic->irc, ":%s!%s@%s TOPIC %s :%s", u->nick, u->user, u->host, c->channel, topic );
     783}
     784
    762785struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle )
    763786{
     
    777800        c->title = g_strdup( handle );
    778801        c->channel = g_strdup_printf( "&chat_%03d", ic->irc->c_id++ );
     802        c->topic = g_strdup_printf( "%s :BitlBee groupchat: \"%s\". Please keep in mind that root-commands won't work here. Have fun!", c->channel, c->title );
    779803       
    780804        if( set_getbool( &ic->irc->set, "debug" ) )
  • protocols/nogaim.h

    rebb95b6 r50e1776  
    110110         * chat using imcb_chat_new(). */
    111111        char *title;
     112        /* Use imcb_chat_topic() to change this variable otherwise the user
     113         * won't notice the topic change. */
     114        char *topic;
    112115        char joined;
    113116        /* This is for you, you can add your own structure here to extend this
     
    212215        struct groupchat *
    213216             (* chat_join)      (struct im_connection *, char *room, char *nick, char *password);
     217        /* Change the topic, if supported. Note that BitlBee expects the IM
     218           server to confirm the topic change with a regular topic change
     219           event. If it doesn't do that, you have to fake it to make it
     220           visible to the user. */
     221        void (* chat_topic)     (struct groupchat *, char *message);
    214222       
    215223        /* You can tell what away states your protocol supports, so that
     
    293301/* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */
    294302G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at );
     303/* To tell BitlBee 'who' changed the topic of 'c' to 'topic'. */
     304G_MODULE_EXPORT void imcb_chat_topic( struct groupchat *c, char *who, char *topic );
    295305G_MODULE_EXPORT void imcb_chat_free( struct groupchat *c );
    296306
Note: See TracChangeset for help on using the changeset viewer.