Example #1
0
static enum v7_err jsBotSay(struct v7 *v7, v7_val_t *res) {
	long argc = v7_argc(v7);
	if (argc == 0) {
		return V7_OK;
	}
	v7_val_t v = v7_arg(v7, 0);
	if (!v7_is_string(v)) {
		return V7_OK;
	}
	TString str = (const char*)v7_to_cstring(v7, &v);
	TString font;
	if (argc >= 2) {
		v7_val_t fontt = v7_arg(v7, 1);
		if (!v7_is_null(fontt) && !v7_is_undefined(fontt)) font = (const char*)v7_to_cstring(v7, &fontt);
	}
	int size = 0;
	if (argc >= 3) {
		v7_val_t sizee = v7_arg(v7, 2);
		if (v7_is_number(sizee)) size = floor(v7_to_number(sizee));
		if (size < 10) size = 10;
	}
	TString col;
	if (argc >= 4) {
		v7_val_t coll = v7_arg(v7, 3);
		if (v7_is_string(coll)) col = (const char*)v7_to_cstring(v7, &coll);
		if (col.GetAt(0) != L'#' || col.GetLength() != 7) col = L"";
	}
	_activeBot->say(str, font, size, col);
	return V7_OK;
}
Example #2
0
int VAISNAVADAY::GetFestivalClass(TString &str)
{
	int i, j, val;

	i = str.Find("[c");

	if (i >= 0)
	{
//		i += 2;
		if ((i + 2) < str.GetLength())
		{
			val = int(str.GetAt(i+2) - '0');
			j = str.Find("]", i);
			if (j >= str.GetLength())
				j = str.GetLength();
			if (j > i)
			{
				str.Delete(i, j - i + 1);
			}
			if (val < 0 || val > 6)
				return -1;
			return val;
		}
		else
			return -1;
	}
	else
	{
		return -1;
	}

}
Example #3
0
DWORD GetCol(const wchar_t* str) {
	int i = 0;
	TString strChk = str;
	if (strChk.GetLength() < 6) return 0;
	if (strChk.GetAt(i) == L'#') i++;
	wchar_t r[2], g[2], b[2];
	r[0] = strChk.GetAt(i++);
	r[1] = strChk.GetAt(i++);
	g[0] = strChk.GetAt(i++);
	g[1] = strChk.GetAt(i++);
	b[0] = strChk.GetAt(i++);
	b[1] = strChk.GetAt(i);
	int rr = h2a2(r);
	int gg = h2a2(g);
	int bb = h2a2(b);
	return RGB(rr, gg, bb);
}
Example #4
0
void VAISNAVADAY::GetFastingSubject(TString &strFest, int &nFast, TString &strFastSubj)
{
	int nf, nf2;

	// default values
	nFast = 0;
	strFastSubj.Empty();

	// finding fast subject
	nf = strFest.Find("[f:");
	if (nf >= 0 && nf < strFest.GetLength())
	{
		// ziskava typ postu
		nFast = strFest.GetAt(nf+3) - '0';
		nf2 = strFest.Find("]", nf);
		if (nf2 >= 0)
		{
			strFest.Mid(nf + 5, nf2 - nf - 5, strFastSubj);
		}
		strFest.Delete(nf, strFest.GetLength() - nf);
	}
}