<?php
class StartPatreonCode extends Intent {
function init(){
$this->name = "startPatreonCode";
// checking /start patbVuhO3XvBgvQonAi3oY9woQuAc79XB
// preg_match('/(\d+((.|,)\d+)?)\S*\s*toman.*/', $input_line, $output_array);
$this->patterns[] = new Pattern('startWithPat',"/\/start pat(.*)/i");
}
function act(){
if(isset($this->data["entities"][0]["value"])){
$code = $this->data["entities"][0]["value"];
$result = $this->getIS()->getTG()->getPatreonService()->oathUserViaCode($code);
if(isset($result)&&$result!=false){
$patreon_plan_id = $result['data']['relationships']['memberships']['data'][0]['id'];
if(isset($patreon_plan_id)){
$this->getIS()->getTG()->sendMessage("خیلی خوش اومدی و ممنون که از ربات لغتنامه حمایت می کنی", $this->getIS()->getTG()->chat_id);
}
else {
$this->getIS()->getTG()->sendMessage("خیلی خوش اومدی و هنوز هیچ کدوم از طرح های ربات لغتنامه رو حمایت نکردی", $this->getIS()->getTG()->chat_id);
}
}
}
}
function getIntentID()
{
return 13;
}
}
?>