Esempio n. 1
0
	void operator()(boost::system::error_code ec, std::size_t bytes_transfered)
	{
		pt::ptree	jsonobj;
		std::istream jsondata( m_buffer.get() );

		/**
		* Here, we got a json object like this:
		* {"retcode":0,"result":{"uiuin":"","account":615050000,"uin":954663841}}
		*
		*/
		//处理!
		try {
			pt::json_parser::read_json( jsondata, jsonobj );

			//TODO, group members
			if( jsonobj.get<int>( "retcode" ) == 0 ) {
				m_this_group->qqnum = jsonobj.get<std::string>( "result.account" );
				BOOST_LOG_TRIVIAL(debug) <<  "qq number of group "
					<<  utf8_to_local_encode(m_this_group->name) << " is " <<  m_this_group->qqnum;

				m_webqq->siggroupnumber(m_this_group);

				m_handler(boost::system::error_code());

				return ;
			}else{
				BOOST_LOG_TRIVIAL(error) << literal_to_localstr("获取群的QQ号码失败");
				pt::json_parser::write_json(std::cerr, jsonobj);
			}
		} catch( const pt::ptree_error & jserr ) {
		}

		// 返回错误
		m_handler(error::make_error_code(error::failed_to_fetch_group_qqnumber));
	}
Esempio n. 2
0
	void call_dll_message(std::string textmsg, std::string channel, boost::function<void(std::string)> sender)
	{
		boost::shared_ptr<void> dll_module;

		dll_module.reset(
			LoadLibraryW(L"avbotextension"),
			[](void * p){
			if (p)
			{
				FreeLibrary((HMODULE)p);
				AVLOG_DBG << literal_to_localstr("已卸载 avbotextension.dll");
			}
		});

		if (dll_module)
		{
			AVLOG_DBG << literal_to_localstr("已加载 avbotextension.dll!!!");
		}
		else
		{
			AVLOG_ERR << literal_to_localstr("没有找到 avbotextension.dll!!!");
			return;
		}
		

		auto p = GetProcAddress((HMODULE)(dll_module.get()), "avbot_on_message");
		avbot_on_message_t f = reinterpret_cast<avbot_on_message_t>(p);

		if (!f)
		{
			MessageBoxW(0, L"avbot_on_message 函数没找到", L"avbotdllextension.dll", MB_OK);
		}

		// 调用 f 吧!
		boost::cfunction<message_sender_t, void(std::string)> sender_for_c = sender;
		f(textmsg.c_str(), channel.c_str(), sender_for_c.c_func_ptr(), sender_for_c.c_void_ptr());

		AVLOG_DBG << "called avbot_on_message()";
	}