#!/bin/bash

[ -d ~/www/goldfarmer/ ] || exit

source ~/.gamerc
cd ~/www/goldfarmer/

echo "copy (select distinct clientip from game_log where mid in ($(
	for bot_account in $(
		for set in $SET_NUMBER_LIST;do 
			for id in `cat get_in_jail-set_$set.txt | awk '{print $NF}'|awk -F\) '{print $1}'|sort|uniq`;do 
				echo "copy (select account_name from player_characters where id=$id) to stdout csv;"
			done|ssh gamedb$set "source ~/.gamerc;game_db"
		done|sort|uniq
);do 
	echo -n "'$bot_account', "
done\
|sed 's/, $//g'))) to stdout csv;"\
|ssh bgw "source ~/.gamerc;member_db"\
|sort -g\
|grep -v "[a-z]"\
|tee $GAME_TYPE-$COUNTRY_CODE-bot_ip_list.txt

\
curl --form upload=@$GAME_TYPE-$COUNTRY_CODE-bot_ip_list.txt http://60.199.246.188/bbl/collect.php
