bool WriteJoke::write_joke(std::string title, std::string content) { std::shared_ptr<Joke>joke(new Joke()); joke->set_title(title); joke->set_content(content); std::shared_ptr<DatabaseOperator>databaseOperator(new DatabaseOperator()); bool result = databaseOperator->jokeManager->write_joke(joke); return result; }
void new_channel_set_extension(boost::asio::io_service &io_service, avbot & mybot , std::string channel_name) { mybot.on_message.connect( joke(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 0)), channel_name, boost::posix_time::seconds(600) ) ); mybot.on_message.connect( ::urlpreview(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); #ifdef ENABLE_LUA mybot.on_message.connect( ::callluascript(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); #endif mybot.on_message.connect( ::bulletin(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); mybot.on_message.connect( ::metalprice(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); mybot.on_message.connect( ::stockprice(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); mybot.on_message.connect( ::exchangerate(io_service, io_service.wrap(boost::bind(sender, boost::ref(mybot), channel_name, _1, 1)), channel_name ) ); }
void new_channel_set_extension(avbot& mybot, avchannel& channel, std::string channel_name) { auto & io_service = mybot.get_io_service(); channel.handle_extra_message.connect( avbot_extension( channel_name, joke( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 0)), channel_name, boost::posix_time::seconds(600) ) ) ); channel.handle_extra_message.connect( avbot_extension( channel_name, urlpreview( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ) ); #ifdef ENABLE_LUA channel.handle_extra_message.connect( make_luascript( channel_name, io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ); #endif channel.handle_extra_message.connect( avbot_extension( channel_name, ::bulletin( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)), channel_name ) ) ); channel.handle_extra_message.connect( avbot_extension( channel_name, make_metalprice( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ) ); channel.handle_extra_message.connect( avbot_extension( channel_name, make_stockprice( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ) ); channel.handle_extra_message.connect( avbot_extension( channel_name, ::exchangerate( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ) ); static std::shared_ptr<iplocationdetail::ipdb_mgr> ipdb_mgr; if (!ipdb_mgr) { // check for file "qqwry.dat" // if not exist, then download that file // after download that file, construct ipdb ipdb_mgr.reset(new iplocationdetail::ipdb_mgr(mybot.get_io_service(), uncompress)); ipdb_mgr->search_and_build_db(); } channel.handle_extra_message.connect( avbot_extension( channel_name, make_iplocation( io_service, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)), ipdb_mgr ) ) ); channel.handle_extra_message.connect( make_static_content(io_service, channel_name) ); #ifdef ENABLE_PYTHON channel.handle_extra_message.connect( make_python_script_engine( io_service, channel_name, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ); #endif #ifdef _WIN32 channel.handle_extra_message.connect( make_dllextention( io_service, channel_name, io_service.wrap(std::bind(sender, std::ref(mybot), channel_name, std::placeholders::_1, 1)) ) ); #endif }