summaryrefslogtreecommitdiff
path: root/src/mods/commands/yc_me.cpp
blob: d9de98c1eed015f6d3f78591b860c979f79bf005 (plain)
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
#include <iostream>
#include "../../chat/user.h"
#include "../../chat/room.h"
/*
 gcc -shared -o yc_name.so yc_name.cpp
*/

using namespace std;

extern "C"
{
  int valid_color( string );

  int extern_function(void *v_arg)
  {
    container *c=(container *)v_arg;

    user *p_user = (user*) c->elem[1];		// the corresponding user
    vector<string> *params= (vector<string>*) c->elem[2];	// param array
    timr* p_timr = (timr*) ((dynamic_wrap*)c->elem[3])->TIMR;
    conf* p_conf = (conf*) ((dynamic_wrap*)c->elem[3])->CONF;

    string s_msg = "";

    if ( p_conf->get_elem("chat.printalwaystime") == "true" )
      s_msg = p_timr->get_time() + " ";

    s_msg.append(  "<i><font color=\"#" +p_user->get_col1() + "\">"
                   + p_user->get_name() + " ");

    if ( ! params->empty() )
    {
      vector<string>::iterator iter = params->begin();
      for ( iter = params->begin(); iter != params->end(); iter++ )
        s_msg.append( *iter + " " );
    }

    s_msg.append( "</font></i><br>\n" );
    p_user->get_room()->msg_post( &s_msg );

    return 0;

  }
}