Java tutorial
////////////////////////////////////////////////////////////////////////////////////////// // 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.Method; import br.shura.venus.function.annotation.MethodArgs; import br.shura.venus.function.annotation.MethodName; import br.shura.venus.value.IntegerValue; import br.shura.venus.value.StringValue; import twitter4j.Status; import twitter4j.Twitter; /** * Tweet.java * * @author <a href="https://www.github.com/BloodShura">BloodShura</a> (Joo Vitor Verona Biazibetti) * @contact joaaoverona@gmail.com * @date 23/05/16 - 20:10 * @since GAMMA - 0x3 */ @MethodArgs(StringValue.class) @MethodName("tweet") public class Tweet extends Method { @Override public IntegerValue call(Context context, FunctionCallDescriptor descriptor) throws ScriptRuntimeException { ConnectedBot bot = context.getApplicationContext().getUserData("bot", ConnectedBot.class); Twitter twitter = bot.getHandler(); StringValue value = (StringValue) descriptor.get(0); Status status = Helper.execute(context, () -> twitter.updateStatus(value.value())); return status != null ? new IntegerValue(status.getId()) : new IntegerValue(0); } }