module Dialog::ModSend

Public Class Methods

atomMux(args, props, viewId, fFqn, tFqn) click to toggle source
# File lib/dialect/canvas/mod/send/func.rb, line 37
def atomMux(args, props, viewId, fFqn, tFqn)  
  muxFqn = tFqn.to_s.split /(?=[A-Z])/
  if muxFqn[0] == 'Dialog'
    if muxFqn[1] == 'Mod' && muxFqn[2] == 'Send'
      Dialog.logger.debug "#### muxFqn #{muxFqn}"                  
      args[:x][:muxFqn] = {}
      args[:x][:muxFqn][3] = "#{muxFqn[0]}#{muxFqn[1]}#{muxFqn[2]}"
      args[:x][:muxFqn][4] = "#{muxFqn[0]}#{muxFqn[1]}#{muxFqn[2]}#{muxFqn[3]}"
      args[:x][:muxFqn][5] = "#{muxFqn[0]}#{muxFqn[1]}#{muxFqn[2]}#{muxFqn[3]}#{muxFqn[4]}"          
      args[:x][:muxFqn][:g] = muxFqn[4]
      run = "set_#{args[:x][:muxFqn][5]}"
      Dialog.logger.debug " @@@ pre-atomMux sender #{run}"                                               
      begin
        send(run.to_sym, args, fFqn, tFqn, props, viewId)                
      rescue NoMethodError => @e
        step = @e.message.split('`')[1].split('\'')[0].split /(?=[A-Z])/
        Dialog.logger.debug " @@@@@@@@@@@@@@@@@@@@ #{step.count} - #{@e.message}"                                               
        
        case step.count
        when 6 #runner
          begin          
            Dialog.logger.debug " @@@ pre-atomMux sender #{step.count} - #{tFqn}"                       
            send("set_#{tFqn}".to_sym, args, fFqn, tFqn, props, viewId)                  
            Dialog.logger.debug " @@@ atomMux sender #{step.count} - #{tFqn}"     
          rescue NoMethodError
            setterDefault(args, fFqn, tFqn, muxFqn[5].downcase, step.count)
          rescue => @e          
            raise
          end                  
        when 7 #setter
          setterDefault(args, fFqn, tFqn, muxFqn[5].downcase, step.count)
        end
      rescue => @e          
        raise
      end
    end
  end
end
call_CompileElementFromAtoms(args, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/func.rb, line 17
      def call_CompileElementFromAtoms(args, props, viewId)   
        args[:smsg] ||= {} 
                  
        if props.has_key?(:add) 
          fFqn = props[:fFqn].to_sym 
          tFqn = props[:tFqn].to_sym
          if args[:x][:exec].has_key?(fFqn)
            args[:x][:exec][fFqn][tFqn] = props[:tProp]
          end
          atomMux(args, props, viewId, fFqn, tFqn)        
        else
          fFqn = props[:tFqn].to_sym         
          args[:x][:exec][fFqn].each do |tFqn, prop|
#             Dialog.logger.debug "@@@@@@@@@@@@@ 1 - fFqn::#{fFqn}, tFqn::#{tFqn}, props::#{props}"
          atomMux(args, props, viewId, fFqn, tFqn)  
          end
        end
      end
makeInline_query_resultArticle(args, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/_Inline_query_result.rb, line 18
def makeInline_query_resultArticle(args, props, viewId)
  result = Array.new
  props[:tProp].to_h.each do |row, hash_col|      
  Dialog.logger.debug "%%%%%%%% row - #{row},  hash_col - #{hash_col}"
    
    hash_col.sort.each do |col, prop|
      Dialog::ModSend.call_CompileElementFromAtoms(args, {fFqn: prop[:modSend][:fFqn], tFqn: prop[:modSend][:tFqn], tProp: prop[:modSend][:tProp][:value], add: true}, viewId)
      base = args[:x][:send][args[:x][:muxFqn][4].to_sym][args[:x][:muxFqn][:g].to_sym]
      result << {id: rand(1 .. 90000), type: "article", title: "#{prop[:tProp][:value]}", input_message_content: {message_text: prop[:modSend][:tProp][:value]}}
      args[:x][:send][args[:x][:muxFqn][4].to_sym][args[:x][:muxFqn][:g].to_sym] = {}
    end
  end

  Dialog.logger.debug "%%%%%%%%2 result - #{result}}"      
  return result            
end
makeKeyboard(args, mode, keyboardButtons) click to toggle source
# File lib/dialect/canvas/mod/send/_keyboards.rb, line 18
      def makeKeyboard(args, mode, keyboardButtons)
        keyboard = Array.new
        keyboardButtons.each do |row, hash_col|      
#           Dialog.logger.debug "%%%%%%%% row - #{row},  hash_col - #{hash_col}"
          keyboard[row.to_i] ||= Array.new
          hash_col.sort.each do |col, prop|
            case mode
            when :reply
              keyboard[row.to_i] << {text: "#{prop[:tValue]}"}
            when :inline
              keyboard[row.to_i] << {text: "#{prop[:tValue]}", prop[:spec][:key] => "#{prop[:spec][:value]}"}
            end
          end
        end
        
        return keyboard.drop(1)            
      end
set_DialogModSendGeneralChatId(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/general/chat.rb, line 18
def set_DialogModSendGeneralChatId(args, fFqn, tFqn, props, viewId)
  
  id = args[:x][:exec][fFqn][tFqn][:value]
  case args[:x][:exec][fFqn][tFqn][:value]
  when '{same}'
    chat_id = args[:mmsg][:fqndata][:o][:chat][:id]
  when '{user}'
    chat_id = args[:mmsg][:fqndata][:o][:from][:id] 
  when /^[:fqndata]*/
    id = "args[:mmsg]#{id}"
    chat_id = binding.eval("#{id}")
  else
    chat_id = args[:x][:exec][fFqn][tFqn][:value]
  end
  setter(args, fFqn,  'chat_id', chat_id)
end
set_DialogModSendGeneralCommonReply_to_message_id(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/general/common.rb, line 18
def set_DialogModSendGeneralCommonReply_to_message_id(args, fFqn, tFqn, props, viewId)
  
  case args[:x][:exec][fFqn][tFqn][:value]
  when '{same}'
    reply_to = args[:mmsg][:fqndata][:o][:msg][:id]        
  else
    reply_to = args[:x][:exec][fFqn][tFqn][:value]
  end
  setter(args, fFqn,  'reply_to_message_id', reply_to)
end
set_DialogModSendGeneralMessage(args, fFqn, tFqn, props, viewId) click to toggle source

Message

# File lib/dialect/canvas/mod/send/general/_heads.rb, line 18
def set_DialogModSendGeneralMessage(args, fFqn, tFqn, props, viewId)
  args[:api] = { op: 'sendMessage'}
  send("set_#{tFqn}".to_sym, args, fFqn, tFqn, props, viewId)
end
set_DialogModSendGeneralMessageText(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/general/message.rb, line 18
    def set_DialogModSendGeneralMessageText(args, fFqn, tFqn, props, viewId)
      if args[:x][:exec][fFqn][tFqn][:value].nil?
        text = 'Text placeholder by low-level code'
      else
#         case args[:x][:exec][fFqn][tFqn][:value]
#         when '{funcdoc}'
          text = args[:x][:exec][fFqn][:text]
#         else
#           text = args[:x][:exec][fFqn][tFqn][:value]
#         end
      end
      setter(args, fFqn,  'text', text)      
    end
set_DialogModSendGeneralUserId(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/general/user.rb, line 18
def set_DialogModSendGeneralUserId(args, fFqn, tFqn, props, viewId)
  
  id = args[:x][:exec][fFqn][tFqn][:value]
  case args[:x][:exec][fFqn][tFqn][:value]
  when '{same}'
    chat_id = args[:mmsg][:fqndata][:o][:from][:id]
  when /^[:fqndata]*/
    id = "args[:mmsg]#{id}"
    chat_id = binding.eval("#{id}")
  else
    chat_id = args[:x][:exec][fFqn][tFqn][:value]
  end
  setter(args, fFqn,  'user_id', chat_id)
end
set_DialogModSendInline_query_resultCommon(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/inline_query_result/common.rb, line 17
def set_DialogModSendInline_query_resultCommon(args, fFqn, tFqn, props, viewId)
  run = "set_#{tFqn}"
  args[:api] = { op: 'answerInlineQuery'}
  #args[:smsg][:inline_query_id] = ??
  send("set_#{tFqn}".to_sym, args, fFqn, tFqn, props, viewId)
end
set_DialogModSendInline_query_resultCommonId(args, fFqn, tFqn, props, viewId) click to toggle source
# File lib/dialect/canvas/mod/send/inline_query_result/common.rb, line 24
def set_DialogModSendInline_query_resultCommonId(args, fFqn, tFqn, props, viewId)
  case args[:x][:exec][fFqn][tFqn][:value]
  when '{same}'
    inline_query_id = args[:mmsg][:fqndata][:g][:inline][:id]
  end
  setter(args, fFqn,  'inline_query_id', inline_query_id)      
    
end
setter(args, fFqn, k, v) click to toggle source
# File lib/dialect/canvas/mod/send/func.rb, line 77
def setter(args, fFqn,  k, v)
  Dialog.logger.debug "## SET to FQN #{fFqn} :: K:#{k}, V:#{v}"
  case v
    when 'True', 'true'
      v = true
    when 'False', 'false'
      v = false
  end

  args[:smsg][k.to_sym] = v
end
setterDefault(args, fFqn, tFqn, k, step) click to toggle source
# File lib/dialect/canvas/mod/send/func.rb, line 89
def setterDefault(args, fFqn, tFqn, k, step)     
  Dialog.logger.debug " @@@ atomMux default pre-setter #{step} tFqn::#{tFqn} - #{k} :: #{args[:x][:exec][fFqn][tFqn]}"                                                                  
  setter(args, fFqn,  k, args[:x][:exec][fFqn][tFqn][:value])
  Dialog.logger.debug " @@@ atomMux default setter #{step} - #{k} :: #{args[:x][:exec][fFqn][tFqn][:value]}"                                                          
end