br.shura.team.mpsbot.venusext.Delete.java Source code

Java tutorial

Introduction

Here is the source code for br.shura.team.mpsbot.venusext.Delete.java

Source

//////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016, Joo Vitor Verona Biazibetti - All Rights Reserved                /
//                                                                                       /
// Licensed under the GNU General Public License v3;                                     /
// you may not use this file except in compliance with the License.                      /
//                                                                                       /
// You may obtain a copy of the License at                                               /
//     http://www.gnu.org/licenses/gpl.html                                              /
//                                                                                       /
// Unless required by applicable law or agreed to in writing, software                   /
// distributed under the License is distributed on an "AS IS" BASIS,                     /
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.              /
// See the License for the specific language governing permissions and                   /
// limitations under the License.                                                        /
//                                                                                       /
// Written by Joo Vitor Verona Biazibetti <joaaoverona@gmail.com>, March 2016           /
// https://www.github.com/BloodShura                                                     /
//////////////////////////////////////////////////////////////////////////////////////////

package br.shura.team.mpsbot.venusext;

import br.shura.team.mpsbot.runtime.ConnectedBot;
import br.shura.venus.exception.runtime.ScriptRuntimeException;
import br.shura.venus.executor.Context;
import br.shura.venus.function.FunctionCallDescriptor;
import br.shura.venus.function.VoidMethod;
import br.shura.venus.function.annotation.MethodArgs;
import br.shura.venus.function.annotation.MethodName;
import br.shura.venus.value.IntegerValue;
import twitter4j.Twitter;

/**
 * Delete.java
 *
 * @author <a href="https://www.github.com/BloodShura">BloodShura</a> (Joo Vitor Verona Biazibetti)
 * @contact joaaoverona@gmail.com
 * @date 27/06/16 - 20:03
 * @since GAMMA - 0x3
 */
@MethodArgs(IntegerValue.class)
@MethodName("delete")
public class Delete extends VoidMethod {
    @Override
    public void callVoid(Context context, FunctionCallDescriptor descriptor) throws ScriptRuntimeException {
        ConnectedBot bot = context.getApplicationContext().getUserData("bot", ConnectedBot.class);
        Twitter twitter = bot.getHandler();
        IntegerValue value = (IntegerValue) descriptor.get(0);

        Helper.execute(context, () -> twitter.destroyStatus(value.value()));
    }
}