This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$PULL_REQUEST_URL | grep -o -E ‘[0–9]+$’ | head -1 | sed -e ‘s/^0\+//’ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
post: | |
— bin/cisetup | |
checkout: | |
post: | |
— git fetch origin — depth=1000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export GITHUB_ACCESS_TOKEN=<your_github_access_token> | |
export PULL_REQUEST_URL=${CI_PULL_REQUEST} | |
export PULL_REQUEST_ID=`echo $PULL_REQUEST_URL | grep -o -E ‘[0–9]+$’ | head -1 | sed -e ‘s/^0\+//’` | |
((bin/bundle exec pronto run -f github_pr -c origin/master)) || true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WebhooksController < ApplicationController | |
skip_before_action :verify_authenticity_token | |
def callback | |
dispatcher.new(webhook, user).process | |
render nothing: true, head: :ok | |
end | |
def webhook | |
params['webhook'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
validates_uniqueness_of :telegram_id | |
def set_next_bot_command(command) | |
self.bot_command_data[‘command’] = command | |
save | |
end | |
def get_next_bot_command | |
bot_command_data[‘command’] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BotMessageDispatcher | |
attr_reader :message, :user | |
def initialize(message, user) | |
@message = message | |
@user = user | |
end | |
def process | |
if user.get_next_bot_command |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
development: | |
bot_token: bot220521163:AAHNZe-njGuJz_6-zwOyR1BKkhyJoGpNPyo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require ‘telegram/bot’ | |
module BotCommand | |
class Base | |
attr_reader :user, :message, :api | |
def initialize(user, message) | |
@user = user | |
@message = message | |
token = Rails.application.secrets.bot_token |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BotCommand | |
class Start < Base | |
def should_start? | |
text =~ /\A\/start/ | |
end | |
def start | |
send_message('Hello! Here is a simple quest game! Type /born to start your interesting journey to the Rails rockstar position!') | |
user.reset_next_bot_command | |
user.set_next_bot_command('BotCommand::Born') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BotCommand | |
class AccomplishTutorial < Base | |
def should_start? | |
text =~ /\A\/accomplish_tutorial/ | |
end | |
def start | |
send_message("It was hard, but it’s over! Models, controllers, views, wow, a lot stuff! Let’s practice now. What do you think about writing a Rails blog? Type /write_blog to continue.") | |
user.set_next_bot_command(‘BotCommand::WriteBlog’) | |
end |