void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
	irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session);
	dump_event (session, event, origin, params, count);

	irc_cmd_join (session, ctx->channel, 0);
}
示例#2
0
void IrcClient::OnConnect(irc_session_t* session , const char*  event , const char* origin ,
                          const char**   params  , unsigned int count                      )
{
  String host       = origin ;
  String message    = params[1] ;
  bool   is_bitlbee = message.startsWith(IRC::BITLBEE_WELCOME_MSG) ;
  String channel    = STRING(NetworkStore[CONFIG::CHANNEL_ID]) ;

DEBUG_TRACE_CONNECTED

  // set actual connected host for this network
  AvCaster::SetValue(CONFIG::HOST_ID , host) ;

  // display connected message
  AddClientChat(IRC::LOGGED_IN_MSG + host) ; AddServerChat(message) ;

  if (is_bitlbee)
  {
    // identify with bitlbee
    String identify_cmd = IRC::BITLBEE_IDENTIFY_CMD + "this->pass" ;

    irc_cmd_msg(session , IRC::BITLBEE_ROOT_CHANNEL , CHARSTAR(identify_cmd)) ;
    //irc_cmd_join(session , IRC::BITLBEE_XMPP_CHANNEL , NULL) ; // FIXME: when to join?
  }
  else irc_cmd_join(session , CHARSTAR(channel) , NULL) ;

  // reset retries counter
  SetRetries(IRC::MAX_N_RETRIES) ;
}
示例#3
0
文件: main.c 项目: Sokrad/ircbot
void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
	sprintf(botnick,"%s",ctx.nick);
	irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session);
	irc_cmd_join (session, ctx->channel, 0);
	currentChannelCount++;
}
示例#4
0
/**
* @brief Connect Event
* Funktion wird aufgerufen, sobald der Bot sich mit dem Server erfolgreich verbunden hat.
* @param session ein Pointer von irc_session_t, Session von der ein Event erzeugt wird.
* @param event ein konstanter char Pointer, Event Name
* @param origin ein konstanter char Pointer, Herkunfts Name
* @param params const char, Liste der Parameter
* @param count ein unsigned int, Anzahl der Parameter
*/
void event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
	irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session);

	irc_cmd_join (session, ctx->channel, 0);
	
	printf("Connected to Server!\n");
}
示例#5
0
void Kommunikater::event_connect (irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
	irc_ctx_t * ctx = (irc_ctx_t *) irc_get_ctx (session);
	irc_cmd_join (session, ctx->channel, 0);

	thread_id_t tid;
	CREATE_THREAD(&tid, myThread, &state);
}
示例#6
0
文件: irc.c 项目: arminius2/apolloim
static void irc_chat_join (PurpleConnection *gc, GHashTable *data)
{
	struct irc_conn *irc = gc->proto_data;
	const char *args[2];

	args[0] = g_hash_table_lookup(data, "channel");
	args[1] = g_hash_table_lookup(data, "password");
	irc_cmd_join(irc, "join", NULL, args);
}
示例#7
0
void event_connect(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count) {
	struct ircbot_context * ctx = (struct ircbot_context *) irc_get_ctx(session);

	DEBUG("event connected")

	ctx->pConnection->mConnected = true;

	for (unsigned int i = 0; i < ctx->pConnection->mChannel.size(); i++)
		irc_cmd_join(session, ctx->pConnection->mChannel[i]->c_str(), 0);
}
示例#8
0
void event_connect(irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count) {
    irc_ctx_t *ctx = (irc_ctx_t*)irc_get_ctx(session);
    irc_thread_data *self = (irc_thread_data*)ctx->self;

    // shutup compiler complaining about unused variables
    (void) event; (void) origin; (void) params; (void) count;

    irc_debug(self, "(%s) connected to irc", ctx->nick);
    irc_cmd_join(session, ctx->channel, 0);
}
示例#9
0
static void on_kick( irc_session_t *session,
                 const char *event,
                 const char *origin,
                 const char **params,
                 unsigned int count) {


    printf("Kicked from %s\n", params[0]);
#ifdef AUTO_REJOIN
    irc_cmd_join(session, params[0], NULL);    
#endif
}
示例#10
0
void
slack_handler_connect(
    irc_session_t *session,
    const char *event,
    const char *origin,
    const char **params,
    unsigned int count) {
    syslog(LOG_INFO, "Connecting To IRC Server");
    irc_ctx_t *ctx = (irc_ctx_t *)irc_get_ctx(session);
    irc_cmd_join(session, ctx->channel, NULL);
    //TODO: Add password handling from ctx object
}
示例#11
0
void GaMatchmakingState::event_connect(irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count)
{
	GaMatchmakingState* pBridge = reinterpret_cast< GaMatchmakingState* >( irc_get_ctx( session ) );
	BcScopedLock< BcMutex > Lock( pBridge->Lock_ );

	for( unsigned int i = 0; i < count; ++i )
	{
		BcPrintf( "event_connect %s, %s\n", origin, params[i] );
	}

	// Join the channel.
	irc_cmd_join( session, pBridge->Channel_, NULL );
}
示例#12
0
void event_connect( irc_session_t *session, const char *event, const char *origin, const char **params, unsigned int count ) {
	TwitchContext *ctx = ( TwitchContext * ) irc_get_ctx( session );
	if ( !ctx ) {
		return;
	}
	
	if ( irc_cmd_join( session, ctx->twitch->channel.c_str(), 0 ) ) {
		ctx->twitch->OnError( irc_errno( session ), irc_strerror( irc_errno( session ) ) );
		return;
	}

	ctx->twitch->status = TWITCH_CONNECTED;
	ctx->twitch->OnConnected();
}
示例#13
0
文件: irc.c 项目: clehner/motobot
static void
event_connect(irc_session_t *session, const char *event, const char *origin,
		const char **params, unsigned int count) {
	irc_t *irc = get_module(session);

	printf("Connected to %s:%u.\n", irc->server, irc->port);

	// Join our channels
	for (channel_t *channel = irc->channels; channel; channel = channel->next) {
		if (irc_cmd_join(session, channel->name, NULL)) {
			fprintf(stderr, "irc: %s\n", irc_strerror(irc_errno(session)));
			return;
		}
	}
}
示例#14
0
void event_connect( irc_session_t *irc_session, const char *event, const char *origin, const char **params, unsigned int count ) {
	ConfigArrayPtr setting;
	char buffer[512];
dump_event (irc_session, event, origin, params, count);
info( "IRC Bot Connected to server: %s", origin );
setting = GetSetting( "IRC Bot Pass" );
if( setting->string_value ){
	snprintf(buffer, sizeof(buffer), "identify %s", setting->string_value );
	irc_cmd_msg(sysconfig.irc_session, "NickServ", buffer);
}
setting = GetSetting( "IRC Channel" );
irc_cmd_join( irc_session, setting->string_value, 0 );

return;
}
示例#15
0
void IRC::event_connect(irc_session_t* session, const char* event, const char* origin, const char** params, unsigned int count)
{
    std::cout << "IRC::event_connect() connected to " << IRC::_sessionServerMap[session].address << std::endl;

    std::vector<ConfigHandler::IRCOptions_Bridge> channels = IRC::_sessionServerMap[session].channelVector;
    std::vector<ConfigHandler::IRCOptions_Bridge>::iterator it;

    // set user modes
    irc_cmd_user_mode(session, "i");

    for(it = channels.begin(); it != channels.end(); it++)
    {
        std::cout << "IRC::event_connect() joining channel " << it->ircChannelName << std::endl;
        irc_cmd_join(session, it->ircChannelName.c_str(), it->ircChannelKey.c_str());
    }
}
bool CslIrcSession::JoinChannel(const wxString& name,const wxString& password)
{
    if (m_state!=STATE_CONNECTED)
        return false;

    CslIrcChannel *channel;

    if ((channel=FindChannel(name)))
    {
        if (channel->Connected)
            return false;
    }
    else
        m_channels.Add(new CslIrcChannel(name,password));

    return irc_cmd_join(m_context.Session,U2A(name),U2A(password))==0;
}
示例#17
0
static void on_notice( irc_session_t *session,
                 const char *event,
                 const char *origin,
                 const char **params,
                 unsigned int count) {

    printf("<%s> %s \n", origin, params[1]);

    if (strcmp(NS_PASSWD_CORRECT, params[1]) == 0) {
        printf("Correct password entered...\n");
        irc_cmd_join(session, bot_channel, NULL);
    } else if (!bot_identified) {
        irc_send_raw(session, "NICKSERV IDENTIFY %s", ns_pass);
        bot_identified = true;
    }
    //irc_cmd_join(bot_session, "#fct", NULL);
}
// internal callback functions
//----
void event_connect( irc_session_t * session, const char * event, const char * origin, const char ** params, unsigned int count )
{
    // auto-join after connection
    IRCSessionContext* p_ctx = static_cast< IRCSessionContext* >( irc_get_ctx( session ) );
    if ( p_ctx->_channel.length() )
        irc_cmd_join( session, p_ctx->_channel.c_str(), 0 );

    // start the callback mechanism for connection
    p_ctx->_p_handler->connected();

    // store actual nick name
    char p_nickbuf[ 128 ];
    irc_target_get_nick( params[ 0 ], p_nickbuf, sizeof( p_nickbuf ) );
    p_ctx->_nickname = p_nickbuf;
    // notify for nickname change
    p_ctx->_p_handler->recvNicknameChange( p_ctx->_channel, p_ctx->_nickname, "" );
}
void ChatNetworkingIRC::send( const std::string& msg, const std::string& channel )
{
    // ignore input if no valid session exists
    if ( !_p_session )
        return;

    if ( !msg.length() )
        return;

    if ( msg[ 0 ] == '/' )
    {
        // check for /msg commands, send them raw
        if ( ( msg.length() > 4 ) && !msg.compare( 0, 4, "/msg" ) )
        {
            std::string cmd = msg.substr( 4, msg.length() );
            irc_send_raw( _p_session, cmd.c_str() );
            return;
        }

        std::vector< std::string > args;
        yaf3d::explode( msg, " ", &args );

        // all commands without arguments go here
        if ( args.size() == 1 )
        {
            if ( args[ 0 ] == "/names" )
            {
                requestMemberList( channel );
            }
            else if ( args[ 0 ] == "/part" )
            {
                requestLeaveChannel( channel );
            }
            else
            {
                recvMessage( channel, "* ", IRC_CMD_LIST );
            }

        }
        // all commands with one single argument go here
        else if ( args.size() == 2 )        
        {
            if ( args[ 0 ] == "/nick" )
            {
                irc_cmd_nick( _p_session, args[ 1 ].c_str() );
            }
            else if ( args[ 0 ] == "/join" )           
            {
                //! TODO: what is "key" about?
                irc_cmd_join( _p_session, args[ 1 ].c_str(), NULL );
            }
            else if ( args[ 0 ] == "/whois" )
            {
                irc_cmd_whois( _p_session, args[ 1 ].c_str() );
            }
            else
            {
                recvMessage( channel, "* ", IRC_CMD_LIST );
            }
        }
    }
    else
    {
        irc_cmd_msg( _p_session, channel.c_str(), msg.c_str() );
    }
}
示例#20
0
void dazeus::Server::join( const std::string &channel, const std::string &key ) {
	irc_cmd_join(IRC, channel.c_str(), key.c_str());
}
示例#21
0
文件: main.c 项目: Sokrad/ircbot
void ircCommands(irc_session_t * session,const char * origin,const char ** params,unsigned int settings)
{
	
	if (settings & QUIT && !strcmp (params[1], "!quit") )
		irc_cmd_quit (session, "Bot wird beendet...");
		
	if(strstr(params[1],botnick))
	{
		irc_cmd_msg(session, params[0][0] =='#' ? params[0] : origin ,"me?");
	}
	
	if (settings & NICK_CHANGE && strstr (params[1], "!nick") == params[1] )
	{
		sprintf(botnick,"%s",params[1] + 6);
		irc_cmd_nick (session, params[1] + 6);
	}

	if(settings & JOIN_PART)
	{	
		if(currentChannelCount < MAX_CHANNELS)
			if (strstr (params[1], "!join") == params[1] )
			{
				irc_cmd_join (session, params[1] + 6,0);
				currentChannelCount++;
			}

		if (strstr (params[1], "!part") == params[1] )
		{
			if(strstr(params[0],ctx.channel) == 0)
			{
				irc_cmd_part (session, params[0]);
				rmChannel(params[0]);
				currentChannelCount--;
			}
			else
			{
				irc_cmd_msg(session,params[0],"Hier geh ich net raus");
			}	
		
		}
	}

	if(settings & GET_TIME && strstr(params[1],"!time"))
	{	
		char tmp[60];
		time ( &rawtime );
		ptm = gmtime ( &rawtime );
	
		sprintf(tmp,"Es ist %2d:%02d\n", (ptm->tm_hour+GMT)%24, ptm->tm_min);
		irc_cmd_msg(session, params[0][0] =='#' ? params[0] : origin ,tmp);
	}

	if(settings & TOPIC_CHANGE)
	{
		if ( !strcmp (params[1], "!topic") )
			irc_cmd_topic (session, params[0], 0);
		else if ( strstr (params[1], "!topic ") == params[1] )
			irc_cmd_topic (session, params[0], params[1] + 7);
	}


	if(strstr(params[1],"!status"))
	{
		char tmp[80];
		sprintf(tmp,"Channelsettings = %d",getChannelSettings(params[0]));
		irc_cmd_msg(session,params[0],tmp);
	}

	if(strstr(params[1],"!set"))
	{
		int settings;
		char line[200];
		char parts[32][32];
		int i = 0;
		
		strcpy(line,params[1]);

		char *ptr =strtok(line," ");

		while(ptr !=NULL)
		{
			sprintf(parts[i],"%s",ptr);
			ptr = strtok(NULL, " ");
			i++;
		}
		
		settings = atoi(parts[2]);

		if(strstr(parts[2],"privmsg"))
		{		
			privmsg_settings = settings;	
		}
		else
		{
			setChannelSettings(parts[1],settings);
		}
	}

	if(strstr(params[1],"!debug"))
	{	
		int i;
		for(i=0;i<MAX_CHANNELS;i++)
			printf("%d=%s=%d\n",i,chansettings[i].channel,chansettings[i].settings);
	}
}
示例#22
0
void IRCSession::join(string_t channel, string_t password) {
  if (irc_cmd_join( session, channel, password))
    throw std::runtime_error{"Could not join channel."};
}